nginx做正向代理

 

 #代理服务器设置
   server {
       resolver 8.8.8.8;
       resolver 114.114.114.114;
       listen 8080;
       access_log /home/lin/proxy.access.log;
       error_log /home/lin/proxy.error.log;
       location / {
           proxy_pass https://$host$request_uri;
           proxy_set_header Host $http_host;
           proxy_ssl_session_reuse off;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;#记录客户端地址,多级代理服务期地址
           proxy_hide_header X-Forwarded-For;#不记录客户端地址
       }
   }

 反向代理到一组服务

upstream backend{
        server 172.16.0.10:8080;
        server 172.16.0.20:8080;
        server 172.16.0.30:8080;
    }

server {
       resolver 8.8.8.8;
       resolver 114.114.114.114;
       listen 8080;
       access_log /home/lin/proxy.access.log;
       error_log /home/lin/proxy.error.log;
       location / {
           proxy_pass http://backend;
           proxy_set_header Host $http_host;
           proxy_ssl_session_reuse off;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;#记录客户端地址,多级代理服务期地址
           proxy_hide_header X-Forwarded-For;#不记录客户端地址
       }
   }

 

posted @ 2019-02-20 21:07  linyouyi  阅读(1271)  评论(0编辑  收藏  举报