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
+8.7k Golang : On lambda, anonymous, inline functions and function literals
+13.9k Golang : Fix cannot use buffer (type bytes.Buffer) as type io.Writer(Write method has pointer receiver) error
+16.7k Golang : Read integer from file into array
+4.6k Javascript : Access JSON data example
+9.6k Golang : Sort and reverse sort a slice of floats
+7k Golang : Array mapping with Interface
+5.7k Linux : Disable and enable IPv4 forwarding
+5.3k Golang : fmt.Println prints out empty data from struct
+24.4k Golang : Change file read or write permission example
+8.7k Golang : Heap sort example
+7.8k Javascript : How to check a browser's Do Not Track status?