Miraage
Miraage

Reputation: 3464

How to restrict apache virtual hosts?

I have one site enabled, for example foobar.com.
But when I open IP address 127.0.0.1 - it's opens my foobar.com.
Whatever maps to 127.0.0.1 in /etc/hosts I open - foobar.com is opened.

How can I configure virtualhost/apache to only allow access from foobar.com?

Apache 2.4, Ubuntu 13.10

Upvotes: 0

Views: 147

Answers (1)

mbirth
mbirth

Reputation: 390

Apache always uses the first VirtualHost as the "default" host. That is, whenever it can't map the requested hostname (127.0.0.1 in your case) to a specific VirtualHost, it will use that default one.

Just define another VirtualHost before the foobar.com one. If you have both in the same configuration, configure the default one first. If you have separate config files, name the "default" one so, that it gets loaded before the foobar.com one. Many Linux distributions use a name like 00-default.conf for the default VHost.

Upvotes: 1

Related Questions