nginx配置示例

 #配置代理
   #=====================================
   #反向代理1
   server{
        listen 89;
        server_name localhost;
        
        #重写后端服务器的location和refresh头
        #proxy_redirect on;  
        location / {
           proxy_pass http://192.168.2.112:8080/;
           index index.html index.htm;
        }
   }
   
   #反向代理2
   server{
        listen 86;
        server_name localhost;
        proxy_redirect off; 
        location / {
           proxy_pass http://127.0.0.1:8011;
           index index.html index.htm;
        }
   }
   #=====================================
   
   
   
   
   #=====================================
   #配置正向代理
   server{
      listen 88;
      resolver 114.114.114.114;
      location / {
         proxy_pass http://$http_host$request_uri;
      }
   }
   

   #配置https正向代理
   #curl -l --proxy 192.168.2.108:443 www.baidu.com
   server{
      resolver 114.114.114.114;
      listen 443;
      location / {
        proxy_pass https://$host$request_uri;
        proxy_buffers 256 4k;
      }
      
   }
   #=====================================
   
   
   
   
   
   #=====================================
   #配置负载均衡
   upstream myFuzaiTest{
   #四种均衡方式。 轮询; weight:权重 ;ip_hash:每个请求会固定一个服务器 ; fair :第三方,按服务器响应时间优先分配(url_hash 按url的hash结果来分配)。
      server 127.0.0.1:8011 weight=3;
      server 127.0.0.1:90   weight=1;
   }
    
    server{
      listen 8077;
      server_name localhost;
      location / {
         proxy_pass http://myFuzaiTest;
         #proxy_set_header Host $host;#将请求头转发给后端服务器
         #proxy_set_header X-Forward_For $remote_addr;#后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
      }
    }
   #=====================================
   
原文地址:https://www.cnblogs.com/Michael-Ben/p/12104654.html