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
+13.8k Golang : Get current time
+20.2k nginx: [emerg] unknown directive "passenger_enabled"
+7.3k Golang : Scanf function weird error in Windows
+16.3k Golang : Execute terminal command to remote machine example
+8.7k Golang : Heap sort example
+11.6k How to tell if a binary(executable) file or web application is built with Golang?
+30.7k error: trying to remove "yum", which is protected
+7.3k Golang : Convert source code to assembly language
+31.2k Golang : bufio.NewReader.ReadLine to read file line by line
+30.3k Get client IP Address in Go
+10.4k Golang : Select region of interest with mouse click and crop from image
+9.6k Random number generation with crypto/rand in Go