我有这样的nginx设置:
/etc/nginx/sites-available/default-ssl.conf:
server {
listen 443 ssl;
server_name my.server.name;
ssl_certificate /etc/letsencrypt/live/my.server.name/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/my.server.name/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
# root /usr/share/nginx/html;
root /var/www/html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location /proxiedhost/ {
rewrite ^/proxiedhost(/.*)$ $1 break;
proxy_pass http://127.0.0.1:6080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
}
<<<< A couple more of these blocks >>>>
}
server {
listen 80;
server_name origin.ticktockhouse.co.uk;
return 301 https://$host$request_uri;
}
/etc/nginx/sites-available/aptrepo.conf:
server {
listen 80; ## listen for ipv4; this line is default and implied
root /home/aptrepo/;
index index.html index.htm;
server_name aptrepo.server.name;
}
我的问题是,当我浏览到http://aptrepo.server.name时,它会自动重定向到https://aptrepo.server.name,我没有letsencrypt证书。当然,我可以得到一个,但我并不特别需要它,并且想要了解为什么会发生这种情况。
我愿意相信它是default-ssl.conf中的服务器块,但我很困惑为什么其他服务器块不是完全独立的。我已经四处寻找解释,但不幸的是大多数文章/问题围绕如何让https重定向到http - 显然我已经解决了一个问题!
答案 0 :(得分:0)
可能是nginx未选择正确的server {}
块的情况。
仅出于测试目的,请尝试发表评论return 301 https://$host$request_uri;
,看看这是否解决了aptrepo.server.name