nginx 配置反代问题


可以用单纯的nginx语法 设置不同目录的 代理么?
例如


 server
{
    listen 80;
    server_name xxx.com;
    location /baidu {
        proxy_redirect off;
        proxy_set_header Accept-Encoding "";
        proxy_set_header Host "baidu.com";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://baidu.com;
}

访问xxx.com/baidu 会代理为 baidu.com

可以用set实现 访问 xxx.com/abc 代理为 abc.com 根据目录的不同自动代理不同的网站么?
该怎么实现呢?

nginx的奇淫技巧 nginx_proxy nginx

库尔提拉斯 10 years, 5 months ago

可否叙述详细点。。。不太明白你的需求是什么 。。如果你想要根据目录不同代理不同的网站 。。。这用nginx代理不太好吧 。。。你可以在你的程序里面写路由呀。。。。

狩泽绘理华 answered 10 years, 5 months ago

Your Answer