我希望能够,如果请求尝试访问< host> /.well-known / acme-challenge /来提供匹配文件(如果找到).
server {
listen 8080;
server_name my_example.com;
location /.well-known/acme-challenge/ {
alias /var/www/encrypt/.well-known/acme-challenge/;
try_files $uri =404;
}
return 301 https://$server_name$request_uri;
}
问题是访问别名路径中存在的my_example.com/.well-known/acme-challenge/12345时,我仍重定向到https://,浏览器未下载文件.
谢谢
最佳答案
将return语句放置在location块中:
原文链接:/nginx/532334.html例如:
server {
listen 8080;
server_name my_example.com;
location /.well-known/acme-challenge/ {
root /var/www/encrypt;
}
location / {
return 301 https://$server_name$request_uri;
}
}
此外,简化了其他位置块.