Redirect Nginx:重定向两者http://example.com 和http://*.example.comhttps://example.com
我只有example.com的SSL证书,希望将和http://*.example.com重定向到使用nginx。我知道在没有包含所有子域的证书的情况下,通过SSL重定向子域是不可能的,但至少,我应该能够将键入www.example.com(端口80)的用户重定向到SSL主页 我当前的nginx配置启动如下:Redirect Nginx:重定向两者http://example.com 和http://*.example.comhttps://example.com,redirect,ssl,nginx,Redirect,Ssl,Nginx,我只有example.com的SSL证书,希望将和http://*.example.com重定向到使用nginx。我知道在没有包含所有子域的证书的情况下,通过SSL重定向子域是不可能的,但至少,我应该能够将键入www.example.com(端口80)的用户重定向到SSL主页 我当前的nginx配置启动如下: server { # This should catch all non-HTTPS requests to example.com and *.example.com
server {
# This should catch all non-HTTPS requests to example.com and *.example.com
listen 80;
server_name example.com *.example.com;
access_log off;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl;
# Actual server config starts here...
请求将正确重定向到,而导致(当然,浏览器显示证书错误)。我认为这与服务器名称值的处理顺序有关,但我没有找到任何关于如何强制执行特定顺序的信息。尝试添加另一个服务器{}
server {
listen 80;
server_name www.example.com
access_log off;
return 301 https://example.com$request_uri;
}
尝试:
直接从Nginx获取
server_name example.com www.example.com *.example.com;