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
+7.2k Golang : Use modern ciphers only in secure connection
+17.4k Golang : Check if IP address is version 4 or 6
+5.4k Unix/Linux : How to archive and compress entire directory ?
+17.8k How to enable MariaDB/MySQL logs ?
+35.3k Golang : Strip slashes from string example
+12.1k Golang : Clean formatting/indenting or pretty print JSON result
+9.8k Golang : Resumable upload to Google Drive(RESTful) example
+30.6k Golang : Remove characters from string example
+6.5k PHP : Shuffle to display different content or advertisement
+5k Nginx and PageSpeed build from source CentOS example
+7.1k Golang : Get Alexa ranking data example
+10.3k Golang : Embed secret text string into binary(executable) file