Nginx做非80端口转发

安装nginx

https://www.cnblogs.com/JiHC/p/15936349.html

修改nginx配置文件

 

whereis nginx
vi /usr/local/nginx/conf/nginx.conf

 

Nginx做非80端口转发

 

 我的配置

    upstream tomcat{
        server localhost:8080;
    }

   server {
        listen       80;
        server_name  tomcat.fahaxiki.top;

        location / {
            proxy_pass http://tomcat;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For     $proxy_add_x_forwarded_for;
            client_max_body_size  100m;
        }
    }

Nginx做非80端口转发

当遇到需要获取真实IP的业务时,还需要添加关于真实IP的配置 

proxy_set_header这句配置是改变http的请求头。

  Host是请求的主机名

  X-Real-IP是请求的真实IP

  X-Forwarded-For表示请求是由谁发起的

 

上一篇:Last reported error: Could not find host matching read preference { mode: "primary" } for


下一篇:批处理BAT:启动easyconnect+远程连接桌面mstsc+删除easyconnect的快捷方式