负载均衡+重定向

upstream orderhelper.lanhaitools.com{ 

     server 222.222.45.138:8001; 

     server 222.222.45.138:8002; 

 } 

 server {

 listen 80 ; 

 root /data/website/orderhelper.lanhaitools.com/wwwroot; 

 index index.php; 

 server_name orderhelper.lanhaitools.com; 

 location / { 

 #try_files $uri $uri/ =404;

 try_files $uri $uri/ /index.php; 

 proxy_pass http://orderhelper.lanhaitools.com;

 } 

#有负载均衡时  下边这注释 否则会直接访问主机

 #location ~ \.php$ { 

 # include snippets/fastcgi-php.conf; 

 # fastcgi_pass unix:/run/php/php7.0-fpm.sock; 

 #} 

#重定向配置

 # location / { 

 # proxy_set_header Host $host;

 # proxy_set_header X-Real-Ip $remote_addr; 

 # proxy_set_header X-Forwarded-For $remote_addr;

 # proxy_pass http://222.222.45.138:8001/; 

 # }

 }

你可能感兴趣的:(负载均衡+重定向)