nginx反向代理简单配置

解决同一台电脑上面多个server需要共享80端口或者域名的问题,Apache的二级域名转发规则没研究明白,于是果断nginx了。

server {
        listen       80;
        server_name  wxpro.orctest.cn;

        location /sitefiles/ {
            root   D:/nginx/html;
        }

       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://localhost:8080;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        access_log logs/wxpro.log;
    } 

server{
    listen 80;
    server_name www.orctest.cn;
    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://www.orctest.cn:8003;
    }
    access_log logs/orchestrallinc.log;
}

server {
    listen 80;
    server_name www.safesoft.cn;
    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://www.safesoft.cn:8001;
    }
    access_log logs/safesoft.log;
}

相关推荐