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
+23.1k Golang : Time slice or date sort and reverse sort example
+5.6k Golang : Skip or discard items of non-interest when iterating example
+4.6k Python : Print unicode escape characters and string
+4.7k Golang : Grab news article text and use NLP to get each paragraph's sentences
+3.6k Javascript : Access JSON data example
+4.6k Unix/Linux/MacOSx : Get local IP address
+12.5k Golang : Compress and decompress file with compress/flate example
+5.6k Unix/Linux : How to get own IP address ?
+25.2k Golang : Find files by extension
+14.1k Golang : How do I get the local IP (non-loopback) address ?
+21.2k Golang : Convert Unix timestamp to UTC timestamp
+6.9k Golang : Load DSA public key from file example