简体   繁体   English

将 NGINX HTTPS 域重定向到新的 HTTPS 域

[英]Redirect NGINX HTTPS domain to new HTTPS domain

After spending hours using duckduckgo, this was the best answer I arrived at and it's still not working to redirect a currently HTTPS domain to a new HTTPS domain.在使用duckduckgo 花费数小时后,这是我得到的最佳答案,但仍然无法将当前的 HTTPS 域重定向到新的 HTTPS 域。

server {
    listen 80;
    listen 443 ssl;
    server_name www.olddomain.com olddomain.com;
    rewrite 301 https://newdomain.com$request_uri;
}

Browser gives Insecure Connection error.浏览器给出不安全的连接错误。

I have also tried things like我也尝试过类似的事情

server {
    listen 443 ssl;
    server_name olddomain.com;
    ssl on;
    ssl_certificate /etc/ssl/certs/OLD.crt;
    ssl_certificate_key /etc/ssl/private/OLD.key;

    #enables all versions of TLS, but not SSLv2 or 3 which are weak and now deprecated.
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    ssl_ciphers "ALLLLLLTTHHISSSS";
    ssl_prefer_server_ciphers on;

    rewrite 301 https://newdomain.com$request_uri;
}

Although this option stops giving an error the rewrite is not working and it goes to a "Welcome to NGINX Page."尽管此选项停止给出错误,但重写不起作用,并转到“欢迎使用 NGINX 页面”。

Try accessing directly https://newdomain.com to check if there is any warning about Insecure Connection or not.尝试直接访问https://newdomain.com以检查是否有任何关于不安全连接的警告。 If so, this means your 1st config is good and that you must work on the newdomain config (check its certificate really is for newdomain).如果是这样,这意味着你的第一个配置是好的,你必须在 newdomain 配置上工作(检查它的证书是否真的适用于 newdomain)。 Browsers are supposed to warn when you're leaving a secure context, and ask your agreement.当您离开安全环境时,浏览器应该发出警告,并征得您的同意。 By the way tell us which browser you are using, and if it is running on a desktop or anything such as a Citrix environment.顺便告诉我们您使用的是哪种浏览器,以及它是否在桌面或任何东西(例如 Citrix 环境)上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM