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
+31.2k Golang : Regular Expression for alphanumeric and underscore
+6.5k Golang : Set horizontal, vertical scroll bars policies and disable interaction on Qt image
+7.5k Golang : Another camera capture GUI application with GTK and OpenCV
+6.3k Golang : Check to see if *File is a file or directory
+29.2k Golang : How to redirect to new page with net/http?
+7.8k Golang : Build and compile multiple source files
+16.3k Golang : [json: cannot unmarshal object into Go value of type]
+7.8k Golang : Handle sub domain with Gin
+50.1k Golang : Check if item is in slice/array
+31.3k Golang : Smarter Error Handling with strings.Contains()
+9.9k Golang : Read until certain character to break for loop
+4.4k Golang : Generate Interleaved 2 inch by 5 inch barcode