我发现这里已经有一些问题了,但没有人帮我解决这个问题。 我今天安装了一个debian 8服务器,对我的域的每个请求都被redirect到https。 现在我正在玩耍,为一个子域创build一个新的ssl证书,因为certbot正在用http访问.well-known目录,所以失败了。 当这个请求被redirect到https时,它不起作用。 我的想法是从redirect排除这个隐藏的目录。
为了testing,我把一个简单的文本放入.well-known / acme-challenge /目录。 每次即时通讯对这个文件的请求仍然redirect。 这是我目前的nginxconfiguration:
server { listen 80 default_server; #listen [::]:80 default_server; server_name test.de www.test.de; root /var/www/html; location /.well-known/acme-challenge { root /var/www/html; allow all; } location / { return 301 https://test.de$request_uri; } } server { listen 443 ssl default_server; listen [::]:443 ssl default_server; include snippets/ssl-test.de.conf; include snippets/ssl-params.conf; root /var/www/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # location ~ /.well-known { # allow all; # } }
任何任何想法?
当我做了类似的事情,我需要添加以下内容:
location /.well-known { root /var/www/html; allow all; try_files $uri =404; } location / { return 301 https://example.com$uri; }
如果没有try_files ,nginx没有关于怎么做的信息( try_files没有默认值)。
另外,在testing时,你需要使用curl或者wget ,它不关心网站的HSTS设置。