Question
Nginx https to http
I have an issue with a freshly configured Nginx setup on Ubuntu 16.04. My site loads fine using http, but I get a connection refused error when I access it using https. I don’t need https at the moment, so I would like to redirect these request to http.
My server block looks almost exactly like the LEMP tutorial (https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04) with the addition of a condition that checks for https, then redirects to http. For some reason, this is not working for me. Any help would be appreciated!
See my edited down server block:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name domain.com www.domain.com;
if ( $https = "on" ) {
return 301 http://$host$request_uri;
}
}
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×