如何在 SSL 中重定向两个域



我有域 englishname.ca,而不是我想重定向到 englishname.com。我做了一些配置,它适用于HTTP,但不适用于https。但是我去 http://englishname.ca,我被重定向到 http://englishname.com 但是当我去 https://englishname.ca 时,我没有被重定向。

这是我的共识:

server {                                                                                                               
        server_name 162.243.216.109 staging.frenchname.com staging.englishname.ca staging.singularenglishname.com;
        add_header X-Frame-Options "SAMEORIGIN";
        rewrite  ^/(.*)$  $scheme://staging.englishname.com/$1 permanent;                                  
} 
server {
        listen 80 default deferred;
        server_name www.englishname.com staging.englishname.com;                               
        root /home/deployer/apps/site/current/public;   
        location ^~ /assets/ {                                                                                         
                gzip_static on;
                expires max;
                add_header Cache-Control public;
        }
        try_files $uri/index.html $uri @unicorn;
        location @unicorn {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_redirect off;
                proxy_pass http://unicorn;
        }
        error_page 500 502 503 504 /500.html;
        client_max_body_size 4G;
        keepalive_timeout 10;
}
server {
        listen 443 default ssl;
        server_name www.englishname.com staging.englishname.com;
        root /home/deployer/apps/site/current/public;
        ssl on;
        ssl_certificate /etc/ssl/certs/www.englishname.crt;
        ssl_certificate_key /etc/ssl/private/www.englishname.key;
        ssl_session_timeout 5m;
        ssl_protocols sslv3 tlsv1 tlsv1.1 tlsv1.2;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;
        location ^~ /assets/ {
                gzip_static on;
                expires max;
                add_header Cache-Control public;
        }
        try_files $uri/index.html $uri @unicorn;
        location @unicorn {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_redirect off;
                proxy_pass http://unicorn;
        }
        error_page 500 502 503 504 /500.html;
        client_max_body_size 4G;
        keepalive_timeout 10;
}

我能做什么?

我找到了答案,我只是添加了这些行:

server {
        listen 443;
        server_name 162.243.216.109 staging.lescollectionneursassocies.com staging.associatedartcollectors.ca staging.associatedartcollector.com;
        add_header X-Frame-Options "SAMEORIGIN";
        rewrite  ^/(.*)$  $scheme://staging.associatedartcollectors.com/$1 permanent;
}

它与乞丐的台词相同,但有listen 443.

最新更新