How do I redirect HTTPS to HTTP on NGINX?

Why is something like that useful? At first look I wasn’t sure if it could be done. But it presented an interesting question.

You might try putting a redirect statement in your config file and restarting your server. Two possibilities might happen:

  1. The server will issue the redirect – what you seem to want.
  2. The server will first do the https exchange, and THEN issue the redirect, in which case, what’s the point?

Will add more if I come up with something more concrete.

UPDATE: (couple of hours later)
You could try this. You need to put this in your nginx.conf file –

server {
       listen 443;
       server_name _ *;
       rewrite ^(.*) http://$host$1 permanent;
 }

Sends a permanent redirect to the client. I am assuming you are using port 443 (default) for https.

server {
    listen      80;
    server_name _ *;
    ...
}

Add this so that your normal http requests on port 80 are undisturbed.

UPDATE: 18th Dec 2016
server_name _ should be used instead of server_name _ * in nginx versions > 0.6.25 (thanks to @Luca Steeb)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)