0

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.

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."

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Case
  • 4,244
  • 5
  • 35
  • 53
  • That should be `return` and not `rewrite`. See [this document](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#return). – Richard Smith Nov 14 '17 at 23:09

1 Answers1

0

Try accessing directly https://newdomain.com to check if there is any warning about Insecure Connection or not. 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). 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.

Eugène Adell
  • 3,089
  • 2
  • 18
  • 34