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
      }
    }
   #=====================================
   

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM