vim /usr/local/nginx/conf/vhosts/proxy.conf
server {
listen 80;
server_name www.baidu.com;
localtion / {
proxy_pass http://ip/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
dig www.baidu.com
查看百度有多少ip
如果后端的机器有多台,还可以用upstream来实现负载均衡
upstream 自定义名字
service ip:端口
service ip
server {
listen 80;
server_name www.baidu.com;
localtion / {
proxy_pass http://自定义的名字/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
时间: 2024-10-21 07:09:25