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
+12.5k Golang : Convert IPv4 address to packed 32-bit binary format
+4.3k Linux : sudo yum updates not working
+5.2k Python : Print unicode escape characters and string
+7.8k Golang : Configure Apache and NGINX to access your Go service example
+15.9k Golang : Find out mime type from bytes in buffer
+31.8k Golang : Copy directory - including sub-directories and files
+10.1k Golang : Generate 403 Forbidden to protect a page or prevent indexing by search engine
+11.6k Golang : Convert a rune to unicode style string \u
+7.6k Golang : Check from web if Go application is running or not
+15.6k Golang : How to reverse elements order in map ?
+10.9k Golang : How to use if, eq and print properly in html template
+11.6k Linux : How to install driver for 600Mbps Dual Band Wifi USB Adapter