Imagine the need to visit Google
[[email protected] vhosts] #vim/usr/local/nginx/conf/vhosts/proxy.conf
server {
Listen 80;
server_name www.baidu.com;
Location/{
Proxy_pass http://180.97.33.107/; #百度的IP
#proxy_set_header Host $host;
}
}
--------------------------
Access test
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/8B/1A/wKioL1hFBcXBQFQvAATeWas4TN8156.jpg "title=" Ng35.jpg "alt=" Wkiol1hfbcxbqfqvaatewas4tn8156.jpg "/>
-----------------------------------------------------------------
Nginx Test Load Balancing: Use the dig command to find another Baidu IP
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/8B/1E/wKiom1hFBtfRRhyKAAFbiSngDSI848.jpg "title=" Ng36.jpg "alt=" Wkiom1hfbtfrrhykaafbisngdsi848.jpg "/>
[[email protected] vhosts] #vim/usr/local/nginx/conf/vhosts/proxy.conf
Upstream baidu{
Server 180.97.33.108:80;
Server 180.97.33.107;
}
server {
Listen 80;
server_name www.baidu.com;
Location/{
Proxy_pass http://baidu/;
Proxy_set_header Host $host; # This line will not open, otherwise the visit would be reported 502
#proxy_set_header X-real-ip $remote _addr;
}
}
-------------------------------------
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/8B/1B/wKioL1hFCVWAE0PJAAOKeO3N3Mg335.jpg "title=" Ng36.jpg "alt=" Wkiol1hfcvwae0pjaaokeo3n3mg335.jpg "/>
This article is from the "Cbo#boy_linux Road" blog, make sure to keep this source http://20151213start.blog.51cto.com/9472657/1879551
Nginx proxy Settings