amuck-landowner

Apache issue with default site.

Hxxx

Active Member
Hi Folks,

Don't know what step I'm missing this time.

Here is what I've done:

1- Disabled default apache site.

2- Create desired apache site

3- Enabled desired apache site.

4- Restart Apache

Since the above doesn't prevent apache from serving the website when being accessed directly through IP, that is: http://IP I went to:

1- Enabled default apache site

2- Created a different folder

3- Pointed default apache site to a different folder.

4- Restart Apache

http://IP still pointing to the new site folder.

Other than using .htaccess to prevent access from IP, am I missing something?

I can create different sites, to different folders, different servernames and they work perfectly each one serving their own folder. But http://IP still point to the first site conf I created.

Must be missing something here. Apache is 2.4

I'll appreciate the help.
 

johnlth93

New Member
they are loaded accordingly, by default the first <VirtualHost> will be served unless explicitly told otherwise.
 

sv01

Slow but sure
try


<VirtualHost YOUR.IP.GOES.HERE>
DocumentRoot "/var/www/html"
RewriteEngine On
RewriteCond %{HTTP_HOST} !^myuglydomain.com$
RewriteRule /.* http://myuglydomain.com/ [R]
</VirtualHost>

*sh** code not work :p
 
Last edited by a moderator:

Hxxx

Active Member
Guys thank you for the reply, but I think that maybe I was not clear enough.

I just dont want the vps to server any virtualhost when accessed through IP.

So if someone goes and type: http://IP-HERE it should deny or just dont work.
 

tortau

New Member
Use:


sudo apachectl -S
You will see the list of configuration loaded (the default and vhosts, as well as the config location/line number). It should help debug things...
 

tchen

New Member
Since the above doesn't prevent apache from serving the website when being accessed directly through IP, that is: http://IP I went to:

1- Enabled default apache site

2- Created a different folder

3- Pointed default apache site to a different folder.

4- Restart Apache

http://IP still pointing to the new site folder.
When you re-enabled the default, make sure it's 00-default in sites-enabled.  Also ensure it has no ServerName that would otherwise preclude it from being used.
 

Leo

New Member
they are loaded accordingly, by default the first <VirtualHost> will be served unless explicitly told otherwise.
This.

I have the follwing set as first VirtualHost in the apache config:


<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName default.blackhole

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
deny from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/blackhole-error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/blackhole-access.log combined
ServerSignature Off
</VirtualHost>

Then I have the VirtualHosts for my sites. This will return permission denied to anyone accessing the webserver with just IP or with a unknown hostname.
 

Hxxx

Active Member
Solved as some of you pointed out: I disabled all sites conf except one, and there I configured all websites, and the first vhost there i pointed it to an empty folder. So yes it works :)

Thank you.
 
Last edited by a moderator:
Top
amuck-landowner