我已经使用 letencrypt 设置了 nginx 以使用 https。我/etc/nginx/conf.d/app.conf的如下(没有server配置其他指令):
server {
location /.well-known/acme-challenge/ {
autoindex on;
root /var/www/certbot/;
}
location / {
return 301 https://$host$request_uri;
}
server_name example.com;
listen 80;
}
server {
listen 443;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
server_name example.com;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location /static/ {
gzip on;
gzip_static on;
gzip_types text/plain text/css text/javascript application/javascript;
gzip_disable "msie6";
alias /static/;
autoindex off;
}
# many other locations
}
Run Code Online (Sandbox Code Playgroud)
当我尝试打开时https://example.com,nginx 返回 …