I have several domains configured for my websites on my VPS.
What I want to achieve is: If a user enters the IP address of my VPS directly on his/her browser, like this: https://X.X.X.X
, I want it to redirect to one of my websites.
I was able to make it work for HTTP (http://X.X.X.X
) like this:
server {
listen 80;
server_name IP_OF_MY_VPS;
return 301 https://example.com$request_uri;
}
However, if the user enters https://X.X.X.X
, it doesn't work. Can someone please help out ?