我對 Nginx 還很陌生,目前正在嘗試代理 weebly 網站(https://ldmryeah.weebly.com/)透過 Nginx 作為反向代理。然而,經過幾次嘗試後,我得到的只是預設的 Weebly 404 頁面。
以下是我嘗試過的一些配置:
# most basic one
location /weebly {
proxy_pass $WEEBLY_ENDPOINT;
}
也在嘗試那個
# tried to emulate how a browser would access to the weebly website
location /weebly {
proxy_pass $WEEBLY_ENDPOINT;
proxy_redirect off;
add_header Host ldmryeah.weebly.com;
proxy_set_header Accept-Encoding "gzip, deflate, br";
proxy_set_header Accept "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9";
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
}
此外,我還嘗試更改 proxy_pass 的後緣以及位置,而不會對結果產生影響。
有人有主意嗎?謝謝
答案1
經過多次嘗試,我成功地使用此配置使其工作
####
# Weebly
####
location /blog/ {
proxy_pass https://<website>.weebly.com/;
proxy_set_header Host <website>.weebly.com;
}
###
# assets
###
location ~ ^/(gdpr|uploads|files|ajax)/ {
proxy_pass https://<website>.weebly.com;
}
請注意,生根系統無法正常工作,但您可以透過直接在 /blog/ 下鍵入頁面來存取它