【发布时间】:2016-11-20 01:04:56
【问题描述】:
我在尝试使用 nginx 服务的子域上有多个站点,其中一些子域使用 SSL 服务,而有些则没有。我在让非 SSL 网站正常服务时遇到了一些麻烦。每当我尝试访问它们时,它们都会立即(使用正确的主机)重定向到 SSL/HTTPS 版本。我在下面附上了我的位置块。我已经阅读了关于请求处理的 nginx 块,但不知道如何强制未加密的主机不被转发。 (http://nginx.org/en/docs/http/request_processing.html)
server {
listen 80;
server_name dev.example.ca dev.example.server2.example.tl;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
include proxy_params;
proxy_pass http://unix:/home/example/example/socket.sock;
}
location /static {
autoindex on;
alias /home/litobro/example/example/static/;
}
}
server {
listen 80;
server_name dutyroster.example.ca;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
include proxy_params;
proxy_pass http://unix:/home/example2/dutyroster/socket.sock;
}
location /static {
autoindex on;
alias /home/example/example2/static/;
}
location /socket.io {
proxy_pass http://unix:/home/example/example2/socket.sock;
proxy_redirect off;
proxy_buffering off;
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
server {
listen 80;
server_name ex3.server2.example.tl example.ca www.example.ca;
location ~ .well-known/acme-challenge/ {
root /var/www/letsencrypt;
default_type text/plain;
}
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name example.ca www.example.ca example.server2.example.tl;
ssl_certificate /etc/letsencrypt/live/example.ca/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.ca/privkey.pem;
include snippets/ssl-params.conf;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
include proxy_params;
proxy_pass http://unix:/home/example/example3/socket.sock;
}
}
我订购了服务器块,以便端口 80 请求有望首先受到打击,但这似乎仍然无法正常工作。在此先感谢您的帮助! (服务器块大部分被剥离了实际域,尽管我认为我在域替换上保持一致)
【问题讨论】:
-
做到了!我的 ssl-params 中有 includeSubdomains。非常感谢!您能否将其作为答案提交,以便我将其标记为已解决?