首页 > 系统应用 > nginx > nginx反向代理
2015
09-10

nginx反向代理

反向代理conf 文件配置

vi test.conf
server
{
    listen 80;
    server_name test.com;
    location / {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://192.168.200.242:80;
    }
    access_log logs/access.log;
}

如果想对后端机器做负载均衡

upstream monitor_server {
    server 192.168.0.131:80;
        server 192.168.0.132:80;
}
 
server
{
    listen 80;
    server_name nagios.xxx123.tk;
    location / {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
        proxy_pass http://monitor_server;
    }
    access_log logs/nagios.xxx123.tk_access.log;
最后编辑:
作者:saunix
大型互联网公司linux系统运维攻城狮,专门担当消防员

留下一个回复