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
+4.9k JavaScript/JQuery : Redirect page examples
+8.5k Golang : GMail API create and send draft with simple upload attachment example
+6.8k Golang : Check if one string(rune) is permutation of another string(rune)
+16.2k Golang : File path independent of Operating System
+11k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+4.4k Facebook : How to place save to Facebook button on your website
+26.2k Golang : Force your program to run with root permissions
+30.6k Golang : bufio.NewReader.ReadLine to read file line by line
+17.1k Golang : [json: cannot unmarshal object into Go value of type]
+12.4k Golang : Convert int(year) to time.Time type
+24.1k Golang : Change file read or write permission example
+14.5k Golang : Search folders for file recursively with wildcard support