Why does Ubuntu 20 default to one domain when IP is used

I have two different domains in public_html… call them domain-1 and domain-2

If you enter the Linode assigned IP address into the browser, it is domain-1 that always comes up.

  1. Why does it default to that?

  2. Is there a way to default it to domain-2

  3. Is there a way to default to a screen saying "Access by IP entry not allowed" or something like that?

Thanks.

1 Reply

I have two different domains in public_html… call them domain-1 and domain-2
 
If you enter the Linode assigned IP address into the browser, it is domain-1 that always comes up.

  • Why does it default to that?

This behavior is probably a function of your web server…not the OS. Since the web server has no way to discriminate between domain-1 and domain-2 if all it has is the IP address, it probably just picks the first site configuration it finds…which, in your case, is for domain-1…and serves that site.

  • Is there a way to default it to domain-2

Try putting the configuration for domain-2 ahead of the configuration for domain-1.

  • Is there a way to default to a screen saying "Access by IP entry not allowed" or something like that?

Probably. Consult your web server documentation…you probably need a mod_rewrite rule on HTTP_HOST…and put whatever you come up with in terms of configuration AHEAD of the configuration for both domain-1 and domain-2. Do a search on serverfault.com.

-- sw

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct