nginx 代理请求

nginx  -t 获取配置位置以及检验配置是否正确

nginx -s reload 重启nginx

配置外部请求的处理

server  {

      listen  80;   #侦听外部请求的端口

     server_name  IP地址;   #侦听外部请求的IP地址或域名

     location  /  {

         proxy_set_header    X-Real-IP   $remote_addr;     #保存外部请求的真实IP地址防止通过代理后IP地址变为Nginx服务器的地址,其中X-Real-IP为自定义变量,可以在服务后台通过req.getHeader("X-Real-IP")的方式获取用户的真实IP地址

         proxy_set_header    X-Forward-For  $proxy_add_x_forwarded_for;  

         proxy_set_header   Host   $http_host;  #

          proxy_set_header  X-Nginx-Proxy   true;

           proxy_pass   http://test;

          proxy_redirect   off;

    }

}
--------------------- 
作者:钟日日 
来源:CSDN 
原文:https://blog.csdn.net/qq_41966938/article/details/81276058 
版权声明:本文为博主原创文章,转载请附上博文链接!

https://www.cnblogs.com/reboot777/p/7226365.html

https://blog.csdn.net/qq_41966938/article/details/81276058

猜你喜欢

转载自blog.csdn.net/txl910514/article/details/83350574
今日推荐