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
+15k Golang : Find location by IP address and display with Google Map
+13.2k Golang : Read XML elements data with xml.CharData example
+7.7k Golang : Handle Palindrome string with case sensitivity and unicode
+5.6k Golang : List all packages and search for certain package
+8.8k nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
+9.3k Golang : Read file with ioutil
+19.1k Golang : How to count the number of repeated characters in a string?
+5.9k Golang : Get Hokkien(福建话)/Min-nan(閩南語) Pronounciations
+8.5k Golang : Combine slices but preserve order example
+50.4k Golang : Disable security check for HTTPS(SSL) with bad or expired certificate
+22k Golang : Read directory content with filepath.Walk()
+20.4k Golang : Saving private and public key to files