In reading through the nginx.org site, it seems like rewrites and if
statements are discouraged. I did figure out how to require http://www.example.com/ by using the following in my server block file:
But doing something similar for 443 doesn’t seem to work.
It works, but you have to add the SSL certificate and respective
key. Note that the root domain must be also in the certificate
otherwise the client will complain about the certificate, not being
able to establish endpoint authentication.
Can someone please help me out or point to a good page on setting up
for this?
Here’s an example. It rewrites from www to the base domain. So just
switch the server names and it will work. Add also a listen directive
for port 80.