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
+6.9k Nginx : Password protect a directory/folder
+15.8k Golang : Get digits from integer before and after given position example
+19.3k Golang : How to count the number of repeated characters in a string?
+6.9k Golang : Find the shortest line of text example
+17k Golang : Covert map/slice/array to JSON or XML format
+6.6k Golang : Skip or discard items of non-interest when iterating example
+19.2k Golang : Delete item from slice based on index/key position
+46.4k Golang : Encode image to base64 example
+13.3k Golang : Verify token from Google Authenticator App
+6.2k Apt-get to install and uninstall Golang
+6k Golang : Dealing with backquote
+6.2k WARNING: UNPROTECTED PRIVATE KEY FILE! error message