前后端分离nginx配置记录

# server 地址
upstream app_servers {
    server x.x.x.51:8080;
    server x.x.x.52:8080;
    server x.x.x.53:8080;
}

server {
    listen       9017;
     
    location / {
        root   /home/webapp/project/;
        try_files $uri $uri/ /index.html;
        index index.html;
    }
}

server {
    listen       80;
    server_name www.xxx.com;
    
    location ^~/admin {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     
        proxy_pass http://127.0.0.1:9017/;
    }

    location ^~/admin/api/ {
        proxy_set_header Host $host;
        # 后台API对接地址
        proxy_pass http://app_servers/api/;
    }
}

大前端知识库收集分享 www.rjxgc.com 壹玖零Tech
搜罗各种前后端奇淫技巧,花式编程思想,日日更新,速来围观吧...

你可能感兴趣的:(前后端分离nginx配置记录)