nginx反向代理-多端口映射 - fzj读你 - CSDN博客

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013067927/article/details/55519590

  1. 代码解释
    1.1 http:www.baidu.test.com默认是80,访问“/”利用反向代理,然后访问本地8083;
    1.2 8083代表本地的前端工程访问地址,前端需要访问后台数据,”/”,继续代理到后台地址9803;
    1.3 这样就做到了只要开通80端口就可以完成多个端口访问。
    1.4 root配置可以是绝对路径,也可是相对路径。
  server {
        listen       80;
        server_name  www.baidu.test.com;#你要填写的域名,多个用逗号隔开
        location / {
            proxy_pass  http://localhost:8083;  
            proxy_set_header Host $host;  
            proxy_set_header X-Real-IP $remote_addr;  
            proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;  
            root   /app/esop_web/esopschool;
            index  index.html;
            try_files $uri $uri/ /index.html;
        }
        location /rest{
            proxy_pass http://localhost:9803; 
            proxy_set_header   Host    $host; 
            proxy_set_header   X-Real-IP   $remote_addr; 
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for; 
        }
    }

Original url: Access
Created at: 2019-05-06 10:21:32
Category: default
Tags: none

请先后发表评论
  • 最新评论
  • 总共0条评论