我有這個從“/”到“/home”的簡單重定向,由燒瓶處理
應用程式.py
@app.route('/') #Redirects to home page
def redirect_home():
return redirect("/home")
當我將它與我的瀏覽器一起使用時,它總是會導致連接超時錯誤,盡管在我的 vps(使用 -L)上使用 cURL 時它確實會正確地導致網頁
我相信這與我的 nginx 設定有關:sites-available
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
我以前在我的舊 vps 上遇到過這個問題,我記得通過在 nginx 配置中添加一些東西來修復它,但我不記得它是什么
uj5u.com熱心網友回復:
嘗試
@app.route('/', methods=['GET']) #Redirects to home page
def redirect_home():
return redirect("/home"), 301
如果沒有解決,請添加請求錯誤..
uj5u.com熱心網友回復:
通過使用以下命令簡單地允許 HTTP 流量通過 nginx 解決了該問題:在此處輸入代碼
ufw allow 'Nginx HTTP'
我對這是如何修復它感到困惑,但在那之后它確實起作用了雖然我不確定為什么它只影響重定向
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/472769.html
