我有这样的配置,但是它仍然没有从http重定向到https。我应该重新订购还是缺少什么?
server {
listen 80;
server_name www.example.me example.me;
error_log /var/log/nginx/examplefront.error_log debug; rewrite_log on;
access_log /var/log/nginx/examplefront.access_log;
location / {
proxy_pass http://exampleme.s3-website.eu-central-1.amazonaws.com;
proxy_http_version 1.1;
proxy_set_header Authorization "";
proxy_hide_header Authorization;
proxy_set_header X-Forwarded-Proto $scheme;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.me/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.me/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
listen 80;
if ($host = www.example.me) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.me) {
return 301 https://$host$request_uri;
} # managed by Certbot
}
答案 0 :(得分:0)
所以我做的是:
-我删除了listen 80;
行
-将server_name example.me www.example.me
添加到具有listen 80;
似乎nginx甚至需要查看server_name
语句才能使用if
。