I'm having some trouble redirecting https requests to my Nginx server when the only the short hostname of the server is used. I tried all combination of examples out there but nothing seems to trigger a redirect/rewrite.
For instance, the server is called web01, and I want all requests to go to https://web01.domain.com. I have the http -> https rewrite working perfectly to the FQDN. However, if I try to go to https://web01, it will proceed try and load the page and obviously error on certificate mismatch. I want it to rewrite the request to the FQDN. How can I configure the rewrite/redirect?
What I have now:
server {
listen *:80;
rewrite ^ https://web01.domain.com$request_uri permanent;
}
server {
listen 443 default ssl;
server_name web01.domain.com;
}
Answer
The issue here is that when you access the server with https://web01
, your browser expects to get an SSL certificate for web01
common name.
However, if your certificate is for the full domain name web01.domain.com
, you will get a certificate error, because the domains do not match.
You will need to get an SSL certificate for web01
common name and configure a corresponding virtual host in your nginx configuration.
Comments
Post a Comment