2017-04-02 122 views
0

通常情況下,做一個反向代理設置時,你有你的後端服務器,看起來像這樣:NGINX反向代理與沒有根子目錄主機

http://localhost:8084/app-root

,你可以proxy_pass

location /app-root { proxy_pass http://localhost:8084; }

它會將www.my-domain.com/app-root代理到內部服務器http://localhost:8084/app-root

太棒了!

有人可以解釋需要在服務器堅持從根託管作爲這樣做的事情:

http://localhost:8084/index.html http://localhost:8084/images/image1.jpg

我想這是通過

http://www.my-domain.com/app/index.html
http://www.my-domain.com/app/images/image1.jpg進行訪問

回答

0

您可以使用重寫nginx。像這樣的東西應該工作

location /app/ { 
    rewrite /app/(.*) /$1 break; 
    proxy_pass   http://localhost:8084; 
}