首頁  >  問答  >  主體

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 根據目錄的不同自動代理不同的網站麼?
該怎麼實現呢?

ringa_leeringa_lee2713 天前569

全部回覆(1)我來回復

  • 怪我咯

    怪我咯2017-05-16 17:24:19

    可否敘述詳細點。 。 。不太明白你的需求是什麼 。 。如果你想要根據目錄不同代理不同的網站 。 。 。這用nginx代理不太好吧 。 。 。你可以在你的程式裡面寫路由呀​​。 。 。 。

    回覆
    0
  • 取消回覆