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
+3.2k Golang : Create zip/ePub file without compression(use Store algorithm)
+8k Golang : Delete files by extension
+2.5k Golang : Convert Chinese UTF8 characters to Pin Yin
+3.9k Swift : substringWithRange() function example
+3.3k Golang : Add ASCII art to command line application launching process
+3.4k Golang : Set or add headers for many or different handlers
+16.4k Golang : Storing cookies in http.CookieJar example
+22.9k Golang : Validate email address with regular expression
+6.9k Golang : Encrypt and decrypt data with x509 crypto
+36.7k Golang : How to check if a string contains another sub-string?
+3.1k Nginx : Password protect a directory/folder
+16.2k Golang : Read directory content with filepath.Walk()