nginx代理详解
[root@LHQ vhosts]# vim proxy.conf
写入如下内容:
upstream aming{
server 61.135.169.125:80;
server 61.135.169.121:80;
}
server {
listen 80;
server_name www.baidu.com;
location / {
proxy_pass http://aming/;
proxy_set_header Host $host;
}
}
(使用一个域名,后端对应多个IP的形式相当于负载均衡)
查看是否有错误:
[root@LHQ vhosts]# /usr/local/nginx/sbin/nginx -t
[root@LHQ vhosts]# /usr/local/nginx/sbin/nginx -s reload
[root@LHQ vhosts]# curl -x127.0.0.1:80 www.baidu.com(把百度的IP指向到本机,然后再访问百度)
[root@LHQ vhosts]# yum install bind*