這種提供靜態內容的嘗試有問題嗎? Proxy/ReverseProxy 是否勝過 Alias,或者我可以要求 Alias 勝過代理商嗎?

這種提供靜態內容的嘗試有問題嗎? Proxy/ReverseProxy 是否勝過 Alias,或者我可以要求 Alias 勝過代理商嗎?

我正在努力讓 Apache 為 Django 專案提供靜態檔案。我的虛擬主機有:

Alias /static/ /home/jonathan/pragmatometer/static/

ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/

但對 /static/css/style.css 的請求是由 Django 進程提供的,而不是對 /home/jonathan/pragmatometer/static/css/style.css 的靜態拉取。

我該怎麼做才能讓別名勝過代理?我可以嘗試為 /load/、/save/、/admin/ 拼湊幾個 ProxyPass / ProxyPassReverse 定義,但這一定是錯誤的方式。

那麼什麼是正確的方法呢?

答案1

是的,ProxyPass在這種情況下獲勝。避免這個問題的方法是:

ProxyPass /static/ !
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/

相關內容