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
+8.9k Golang : Gorilla web tool kit schema example
+19.8k Golang : Get current URL example
+10.1k Golang : Turn string or text file into slice example
+7.6k Golang : Rename part of filename
+5.7k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+5.6k Golang : Display advertisement images or strings on random order
+8.3k Golang : HttpRouter multiplexer routing example
+7.2k Golang : Validate credit card example
+17.8k Convert JSON to CSV in Golang
+14.4k Elastic Search : Mapping date format and sort by date
+18k Golang : How to make a file read only and set it to writable again?
+19.9k Golang : Archive directory with tar and gzip