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
+5.1k Golang : Selection sort example
+25.5k Golang : How to check if a connection to database is still alive ?
+9.5k Golang : Create matrix with Gonum Matrix package example
+16.1k Golang : Multi threading or run two processes or more example
+34k Golang : How to split or chunking a file to smaller pieces?
+6.2k Golang : How to stop user from directly running an executable file?
+7.7k Golang : Gonum standard normal random numbers example
+19.1k Golang : Pipe output from one os.Exec(shell command) to another command
+6.7k Golang : How to execute code at certain day, hour and minute?
+27.9k Golang : missing Git command
+8.6k Javascript : Read/parse JSON data from HTTP response