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
+4.6k Linux/MacOSX : How to symlink a file?
+5.2k Javascript : Shuffle or randomize array example
+8.1k Prevent Write failed: Broken pipe problem during ssh session with screen command
+13.1k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message
+7.7k Golang : Scan files for certain pattern and rename part of the files
+9.4k Golang : Extract or copy items from map based on value
+19.5k Golang : Set or Add HTTP Request Headers
+7k Golang : Squaring elements in array
+6.8k Nginx : Password protect a directory/folder
+12.8k Golang : Get terminal width and height example
+6.2k Golang : How to search a list of records or data structures