{"action":"created","issue":{"url":"https://api.github.com/repos/bolin-L/nicon/issues/3","repository_url":"https://api.github.com/repos/bolin-L/nicon","labels_url":"https://api.github.com/repos/bolin-L/nicon/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/bolin-L/nicon/issues/3/comments","events_url":"https://api.github.com/repos/bolin-L/nicon/issues/3/events","html_url":"https://github.com/bolin-L/nicon/issues/3","id":325957051,"number":3,"title":"请问，如果前端静态资源与后端服务部署不在同一台机器，nginx概如何配置？","user":{"login":"supreme94","id":9948889,"avatar_url":"https://avatars2.githubusercontent.com/u/9948889?v=4","gravatar_id":"","url":"https://api.github.com/users/supreme94","html_url":"https://github.com/supreme94","followers_url":"https://api.github.com/users/supreme94/followers","following_url":"https://api.github.com/users/supreme94/following{/other_user}","gists_url":"https://api.github.com/users/supreme94/gists{/gist_id}","starred_url":"https://api.github.com/users/supreme94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supreme94/subscriptions","organizations_url":"https://api.github.com/users/supreme94/orgs","repos_url":"https://api.github.com/users/supreme94/repos","events_url":"https://api.github.com/users/supreme94/events{/privacy}","received_events_url":"https://api.github.com/users/supreme94/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-24T04:09:03Z","updated_at":"2018-05-25T00:55:39Z","closed_at":null,"author_association":"NONE","body":""},"comment":{"url":"https://api.github.com/repos/bolin-L/nicon/issues/comments/391909430","html_url":"https://github.com/bolin-L/nicon/issues/3#issuecomment-391909430","issue_url":"https://api.github.com/repos/bolin-L/nicon/issues/3","id":391909430,"user":{"login":"bolin-L","id":13375016,"avatar_url":"https://avatars1.githubusercontent.com/u/13375016?v=4","gravatar_id":"","url":"https://api.github.com/users/bolin-L","html_url":"https://github.com/bolin-L","followers_url":"https://api.github.com/users/bolin-L/followers","following_url":"https://api.github.com/users/bolin-L/following{/other_user}","gists_url":"https://api.github.com/users/bolin-L/gists{/gist_id}","starred_url":"https://api.github.com/users/bolin-L/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bolin-L/subscriptions","organizations_url":"https://api.github.com/users/bolin-L/orgs","repos_url":"https://api.github.com/users/bolin-L/repos","events_url":"https://api.github.com/users/bolin-L/events{/privacy}","received_events_url":"https://api.github.com/users/bolin-L/received_events","type":"User","site_admin":false},"created_at":"2018-05-25T00:55:39Z","updated_at":"2018-05-25T00:55:39Z","author_association":"OWNER","body":"假定你有两台机器，正常情况下也就需要两个域名，前端资源服务器A，  node应用服务器B ，基本就是在A服务器的nginx配置中把异步接口的请求转发到B服务器上，然后B服务器再配置nginx拦截请求就好了\r\n\r\n// A 服务器\r\n`\r\nserver {\r\n    listen 80;\r\n    listen [::]:80;\r\n\r\n    server_name icon.bolin.site;\r\n\r\n    access_log   /var/log/nginx/bolin_sites_icon.access.log main;\r\n    error_log    /var/log/nginx/bolin_sites_icon.error.log;\r\n\r\n    include common.conf;\r\n    # 静态资源请求\r\n    location / {\r\n        root /home/liaobolin/app/nicon-front/dist;\r\n        index index.html index.htm;\r\n    }\r\n    \r\n    location ^~ /static {\r\n        root /home/liaobolin/app/nicon-front/dist;\r\n    }\r\n\t# 配置异步接口请求到服务器\r\n    location /api {\r\n\t// 转发到B服务 b.bolin.site\r\n    }\r\n\t# 服务端的字体文件资源请求\r\n    location ^~ /resource {\r\n       // 转发到B服务 b.bolin.site\r\n    }\r\n}\r\n`\r\n\r\n\r\n// B 服务器\r\n`\r\nserver {\r\n    listen 80;\r\n    listen [::]:80;\r\n\r\n    server_name b.bolin.site;\r\n\r\n    access_log   /var/log/nginx/bolin_sites_icon.access.log main;\r\n    error_log    /var/log/nginx/bolin_sites_icon.error.log;\r\n\r\n    include common.conf;\r\n  \r\n   # 配置异步接口请求到服务器\r\n    location /api {\r\n\tproxy_set_header   X-Real-IP $remote_addr;\r\n        proxy_set_header   Host      $http_host;\r\n        proxy_pass http://127.0.0.1:4843;\r\n    }\r\n\t# 服务端的字体文件资源请求\r\n    location ^~ /resource {\r\n        root /home/b/app/nicon;\r\n    }\r\n}\r\n`\r\n\r\n大体思路就是这样，你可以试试"}}
{"actor":{"display_login":"bolin-L"}}