我有一個子,我嘗試使用nginx的,一些子域名被服務使用SSL,有些則不是服務於多個網站。我在使非SSL網站正常運行方面遇到了一些麻煩。每當我嘗試訪問它們時,它們都會立即將(使用正確的主機)重定向到SSL/HTTPS版本。我在下面附加了我的位置塊。我已經閱讀了nginx塊的請求處理,但無法弄清楚如何強制未加密的主機不能轉發。 (http://nginx.org/en/docs/http/request_processing.html)的Nginx服務器塊排序
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中包含了子域名。謝謝一堆!你能否提出這個答案,以便我可以標記這個解決方案? – Litobro