bolin-L / nicon

字体图标管理平台 http://icon.bolin.site/#/
Apache License 2.0
177 stars 35 forks source link

请问,如果前端静态资源与后端服务部署不在同一台机器,nginx概如何配置? #3

Closed supreme94 closed 6 years ago

bolin-L commented 6 years ago

假定你有两台机器,正常情况下也就需要两个域名,前端资源服务器A, node应用服务器B ,基本就是在A服务器的nginx配置中把异步接口的请求转发到B服务器上,然后B服务器再配置nginx拦截请求就好了

// A 服务器

server {
    listen 80;
    listen [::]:80;

    server_name icon.bolin.site;

    location / {
        root /home/liaobolin/app/nicon-front/dist;
        index index.html index.htm;
    }

    location ^~ /static {
        root /home/liaobolin/app/nicon-front/dist;
    }

    location /api {
    // 转发到B服务 b.bolin.site
    }

    location ^~ /resource {
       // 转发到B服务 b.bolin.site
    }
}

// B 服务器

server {
    listen 80;
    listen [::]:80;

    server_name b.bolin.site;

    location /api {
    proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass http://127.0.0.1:4843;
    }

    location ^~ /resource {
        root /home/b/app/nicon;
    }
}

大体思路就是这样,你可以试试

supreme94 commented 6 years ago

@bolin-L 如果我想用账号登录,但是想用七牛上传 这样写对吗?export productType='qiniu';

bolin-L commented 6 years ago

@supreme94 在develop分支中正在开发可视化配置安装的功能,现在基本完成了 你可以试试, 按照你的情况,你只需要配置productType 为default_qiniu 就好了 ,等我测试稳定了才会合回master,有什么提随时可以联系我