nginx反向代理三台web服務器,實現負載均衡


修改nginx.conf

#在http和server之間加入這個模塊 
upstream guaji{
server 127.0.0.1:8080;
server 127.0.0.2:8080;
server 127.0.0.3:8080; }

nginx.conf的server

server {
  listen 80;
  server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
   proxy_pass http://guaji;
    # root html;
    #index index.html index.htm; }
}
修改nginx1.conf
server {
        listen       8080;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html;
index index.html index.htm; }
}

修改nginx.conf(第二個從機)

server {
listen 8080;#只修改這里
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm; }
}

同理修改第三個從機的nginx.conf

修改index.html

然后重啟就ok


免責聲明!

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



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