How to redirect https://ip to https://domain

I have Digital Ocean Droplet, Ubuntu and Apache2 server.

I have let’s encrypt on my https://domain name. I have been able to redirect my http://ip to my https://domain.

But my https://ip is exposed to the public. Also it is not secured.

How can I redirect my https://ip to https://domain name.

This is what I have tried with my VirtualHost

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/public
ServerName https://ip
ServerAlias *
   Redirect / https://domain

But all my https://domain is now having ending redirecting with code 302

1 Like

You would have to get a certificate for your IP to redirect https from it, but Let’s Encrypt doesn’t issue IP address certificates.

Other commercial certificate authorities issue these but they are typically expensive and require complex validation, such as your organization being listed in the RIR registry data to prove ownership.


Hi @rufai

that's not required. No website uses such a redirect.

And one ip address can host a lot of different websites. So it's not a good idea to create such a redirect.

If someone connects the ip address -> it's a bot or a test -> ignore it.


Or a very old browser client - that doesn’t support SNI.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.