如果我在nginx中配置了301跳转,证书将无法自动更新
如
server {
listen 80;
server_name domin.com;
return 301 https://domin.com$request_uri;
}
作者能否提供一个参数,在更新的时候使用指定的nginx配置脚本?
301 应该不影响.
贴出来 log --debug 2
中断更新过程得到acme.sh给nginx的配置:
server {
listen 80;
server_name test.domain;
#ACME_NGINX_START
location ~ "^/\.well-known/acme-challenge/([-_a-zA-Z0-9]+)$" {
default_type text/plain;
return 200 "$1.8XXaeMDlCDC7zI7C5OLAEEBxqFDrP3PVZdrcacWgcxQ";
}
#NGINX_START
return 301 https://$host$request_uri;
}
问题出在这个配置似乎不是顺序执行的??
curl test.domain/.well-known/acme-challenge/123 得到的是:
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.12.1</center>
</body>
</html>
把return 301那行注释掉之后才能得到正确的结果
32432.8XXaeMDlCDC7zI7C5OLAEEBxqFDrP3PVZdrcacWgcxQ
对没错nginx的确不是执行第一个匹配到的location,参考 https://serverfault.com/questions/836504/does-order-of-lines-matter-in-nginx 猜的.
将return 301也放进location块里就能解决问题,如下:
server {
listen 80;
server_name test1.domain;
location / {
return 301 https://$host$request_uri;
}
}
@rewqazxv 正解,301跳转使用了
location / {
return 301 https://$host$request_uri;
}
就能自动更新了
@AriaLyy 那现在必须去掉301,才可以更新吗
Most helpful comment
对没错nginx的确不是执行第一个匹配到的location,参考 https://serverfault.com/questions/836504/does-order-of-lines-matter-in-nginx 猜的.
将
return 301也放进location块里就能解决问题,如下: