nginx 根據端口不同實現負載均衡


upstream www.abc.com {
server www.mynginx.com:91;
server www.mynginx.com:92;
}
server {
listen 80;
server_name www.mynginx.com;
location / {
root D:/www/mynginx;
index index.html index.htm index.php;
proxy_pass http://www.abc.com;
proxy_set_header X-Real-IP $remote_addr;
}
location ~ \.php$ {
root D:/www/mynginx;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 91;
server_name www.mynginx.com:91;
location / {
root D:/www/nginx01;
index index.html index.htm index.php;

}
location ~ \.php$ {
root D:/www/nginx01;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 92;
server_name www.mynginx.com:92;
location / {
root D:/www/nginx02;
index index.html index.htm index.php;
}
location ~ \.php$ {
root D:/www/nginx02;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
然后訪問http://www.mynginx.com,其實是輪流訪問www.mynginx.com:91,www.mynginx.com:92
 




免責聲明!

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



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