How to automatically redirect all port 80 HTTP requests on a NGINX server to port 443 SSL

About redirecting port 80 (HTTP) requests to port 443 (SSL) on an NGINX server

These days all websites require SSL to be installed otherwise the browser will throw an error. Once you have a certificate installed a good idea is to always redirect all port 80 requests to port 443. To do this on an NGINX server, add the following server section. Please note that you might end up with multiple server sections, that is not a problem.

server {
   server_name your_domain_name.com;
   listen server_ip_address:80;
   rewrite ^/(.*) https://your_domain_name.com/$1 permanent;
}

See also

How can I redirect Apache (Virtualmin) website to port 443

Share this article

1 thought on “How to automatically redirect all port 80 HTTP requests on a NGINX server to port 443 SSL”

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top