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
+11.4k Golang : Characters limiter example
+16.5k Golang : Send email and SMTP configuration example
+16.1k Golang : How to reverse elements order in map ?
+7k Golang : Levenshtein distance example
+7.1k Golang : How to call function inside template with template.FuncMap
+10.2k Golang : Print how to use flag for your application example
+10.2k Golang : Compare files modify date example
+7.6k Gogland : Single File versus Go Application Run Configurations
+9.8k Golang : Load ASN1 encoded DSA public key PEM file example
+55.4k Golang : Unmarshal JSON from http response
+17.1k Golang : How to save log messages to file?
+4.7k JavaScript : Rounding number to decimal formats to display currency