Configuring https redirection in Nginx

Enfield Cat's Blog: Arduino and other projects.


To configure a redirect to https from any URL on http in Nginx, use a server stanza similar to the following, using either a 301 (moved permanently) or 302 (moved temporarily), or 307 (moved temporarily) return code:

server {
        listen 80 ;
        listen [::]:80 ;
        return 301 https://$host$request_uri;
        add_header X-Frame-Options "SAMEORIGIN";
}



Thank you for visiting camelthorn.cloudHome