nginx : force all pages to be SSL
With man-in-the-middle attacking becoming more frequent like government censorship. It would be a good idea to server all web pages through SSL channels to minimize man-in-the-middle attack. To do so, you need to redirect all non SSL page to SSL page with Nginx and to achieve this with Nginx, add this line into the server block
rewrite ^ https://$server_name$request_uri? permanent;
just right below the server_name
Remember, just put this line once in the non-SSL server block and NOT in the SSL server block as this will cause infinite loop.
See also : nginx: [emerg] unknown directive "ssl"
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+5.3k Linux/Unix/PHP : Restart PHP-FPM
+14.2k Golang : Find commonalities in two slices or arrays example
+14.4k Golang : Basic authentication with .htpasswd file
+15.4k Golang : Update database with GORM example
+32.3k Golang : How to check if a date is within certain range?
+18k Golang : Logging with logrus
+14.5k Golang : package is not in GOROOT during compilation
+17.6k Golang : Convert IPv4 address to decimal number(base 10) or integer
+14k Golang : How to get URL port?
+10.3k Golang : Get currencies exchange rates example
+4.9k Python : Convert(cast) string to bytes example
+9.1k Golang : Extract or copy items from map based on value