nginx redirect HTTPS to HTTP nginx redirect HTTPS to HTTP nginx nginx

nginx redirect HTTPS to HTTP


The answer above will work, you need to generate a self signed cert (or have a real one) and configure nginx as such:

server {  listen *:443;  ssl on;  server_name domain.com;  rewrite ^(.*) http://domain.com$1 permanent;  ssl_certificate      /data/certs/domain.crt;  ssl_certificate_key  /data/certs/domain.key;  }

Keep in mind, if it is a self signed cert the browser will give you an ugly warning.


Building off jberger's comment a configuration that should work would be:

server {    listen *:80;    server_name example.com;}server {    listen              *:443 ssl;    server_name         example.com;    ssl_certificate     /etc/ssl/certs/example.com.cert;    ssl_certificate_key /etc/ssl/private/example.com.key;    return 301 http://$server_name$request_uri;}


    if ($host = 'foo.com') {        rewrite  ^/(.*)$  http://www.foo.com$1  permanent;    }