我使用dockerwithnginx這是我的app組態檔:
server {
listen 80;
server_name app.me.site;
return 308 https://$host$uri;
location .well-known {
root /var/www/.well-known;
try_files /$uri /$uri/ /index.html;
}
# other configs
}
路徑是/var/www/app。
我還/var/www/.well-known為 Let's Encrypt 創建了它,它是可訪問的,但它只能用于https.
我需要一個if線索:如果 URL 是app.me.site/.well-known,請不要使用https.
我試圖達到這一點,但沒有找到任何線索。
uj5u.com熱心網友回復:
您的配置不可行,因為該return指令是在稍后執行的,NGX_HTTP_SERVER_REWRITE_PHASE而正確的位置選擇將在稍后完成NGX_HTTP_FIND_CONFIG_PHASE(請求處理階段在開發指南中描述)。要修復它,您應該將該return指令移動到location塊中(我還建議使用$request_uri變數而不是規范化的變數$uri):
location / {
# everything not started with the '/.well-known/' prefix will be processed here
return 308 https://$host$request_uri;
}
location /.well-known/ {
# do not append '/.well-known' suffix here!
# (see the difference between 'root' and 'alias' directives)
root /var/www;
try_files $uri =404;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/432651.html
標籤:nginx
下一篇:在Loki中洗掉部分日志
