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
+12.5k Golang : How to check if a file is hidden?
+4.9k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+14.1k Golang : Get checkbox or extract multipart form data value example
+7.7k Golang : Get curl -I or head data from URL example
+12.4k Golang : Reverse IP address for reverse DNS lookup example
+25.8k PHP : Count number of JSON items/objects
+7.1k Golang : Number guessing game with user input verification example
+53.1k Golang : Unmarshal JSON from http response
+80.8k Golang : How to convert character to ASCII and back
+14.8k Golang : Find out mime type from bytes in buffer
+18k Golang : Convert seconds to human readable time format example
+10k Google Maps URL parameters configuration