Ste*_*anM 1 debian nginx lets-encrypt
我发现这里已经有一些问答关于这个话题,但没有一个能帮助我解决这个问题。我今天刚刚安装了一个 debian 8 服务器,对我的域的每个请求都被重定向到 https。现在我正在尝试为子域创建一个新的 ssl 证书,该证书失败了,因为 certbot 正在使用 http 访问 .well-known 目录。由于此请求被重定向到 https,因此无法正常工作。我的想法是从重定向中排除这个隐藏目录。
为了测试,我将一个简单的文本放入 .well-known/acme-challenge/ 目录中。每次我对这个文件发出请求时,我仍然会重定向。这是我当前的 nginx 配置:
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;
# }
}
Run Code Online (Sandbox Code Playgroud)
有人有什么想法吗?
当我做类似的事情时,我需要添加以下内容:
location /.well-known {
root /var/www/html;
allow all;
try_files $uri =404;
}
location / {
return 301 https://example.com$uri;
}
Run Code Online (Sandbox Code Playgroud)
没有try_files,nginx 没有关于做什么的信息(没有默认值try_files)。
此外,在测试时,您需要使用curlor wget,它不关心站点的 HSTS 设置。
| 归档时间: |
|
| 查看次数: |
2360 次 |
| 最近记录: |