Apache config help

Hi,

My apache server responds to requests for domains that it is not configured for. There is something wrong with my virtual host configuration. Though, I tried a couple of different things myself, I couldnt solve it yet.

I have 4 sites configured on my apache.

1- example.com.conf

 <virtualhost *:80="">ServerAdmin admin@example.com                                                                    
     ServerName www.example.com                                                                      
     DocumentRoot /var/www/example.com/public_html/                                                   
     ErrorLog /var/www/example.com/logs/error.log                                                     
     CustomLog /var/www/example.com/logs/access.log combined</virtualhost> 

2- drop.example.com.conf

 <virtualhost *:80="">ServerAdmin admin@example.com                                                                    
     ServerName drop.example.com                                                                      
     DocumentRoot /var/www/drop.example.com/public_html/                                                   
     ErrorLog /var/www/drop.example.com/logs/error.log                                                     
     CustomLog /var/www/drop.example.com/logs/access.log combined</virtualhost> 

3- webmail.example.com.conf

I use this only to forward http requests to https

 <virtualhost *:80="">ServerAdmin admin@example.com                                                                   
     ServerName webmail.example.com                                                                  
     Redirect / https://webmail.example.com</virtualhost> 

4- s.webmail.example.com.conf

 <ifmodule mod_ssl.c=""><virtualhost *:443="">                                                                           
     ServerAdmin admin@example.com                                                                    
     ServerName webmail.example.com                                                                   
     DocumentRoot /var/www/webmail.example.com/public_html/                                           
     ErrorLog /var/www/webmail.example.com/logs/error.log                                             
     CustomLog /var/www/webmail.example.com/logs/access.log combined                                  

SSLEngine on                                                                                          

SSLCertificateFile      /etc/ssl/localcerts/example.pem                                              
SSLCertificateKeyFile /etc/ssl/localcerts/example.key                                                

        </virtualhost></ifmodule> 

Everything works fine with this config but the problem is it also works extra.

I have an DNS entry like xyz.example.com and when I try to reach that domain name through my browser like http://xyz.example.com Virtual Host #2 is being served and when I try to reach it with a secure connection like https://xyz.example.com the site #4 is being served by apache.

I don't want that. I don't want any sites being served from my apache unless I specifically configure for it and yet I don't have a configuration for xyz.example.com

I tried a couple of things myself, like using ServerAlias directive and some more but didn't help so far.

Please help me to configure my apache properly.

Thanks…

6 Replies

Try running this command

commandX 

If that doesn't work, try

commandY

followed by

commandZ

Or maybe you could post the real info so that people don't have to waste their time playing 20 questions.

Repeat this little mantra a few hundred times: "Security thru Obscurity is a MYTH"

This explains what Apache is doing: https://httpd.apache.org/docs/2.2/vhosts/details.html

@vonskippy

Thank you so much for taking the time, appreciated.

I hope you solve you issues (whatever they are) and be happy with your life soon.

@vonskippy:

Try running this command

commandX 

If that doesn't work, try

commandY

followed by

commandZ

Or maybe you could post the real info so that people don't have to waste their time playing 20 questions.

Repeat this little mantra a few hundred times: "Security thru Obscurity is a MYTH"

vonskippy is critical of people who ask for help, yet obscure publically available information (server names, etc). Most of the rest of us just ignore posts like that. If we can't see it, we can't help fix it.

duraturk,

In case you haven't resolved your issue yet you should know that the 'default' site served is the first to occur alphabetically in your sites-available directory. This happens when your IP address is used to connect to your server or a subdomain that isn't defined in a vhost file. BTW, if you use a '@' A Record in your DNS any subdomain will end up getting to your server.

What I do is set up a vhost file for my server's IP address (filename is the IP address and the ServerName is the IP address). The index.html file is empty so any access via the IP address or a non-existent subdomain ends up serving up the empty page. This works because alphabetically the IP address occurs before any alphabetic site.

Ohhh yeah, I did like you said and it works just fine :)

Thank you so much….

@Main Street James:

duraturk,

In case you haven't resolved your issue yet you should know that the 'default' site served is the first to occur alphabetically in your sites-available directory. This happens when your IP address is used to connect to your server or a subdomain that isn't defined in a vhost file. BTW, if you use a '@' A Record in your DNS any subdomain will end up getting to your server.

What I do is set up a vhost file for my server's IP address (filename is the IP address and the ServerName is the IP address). The index.html file is empty so any access via the IP address or a non-existent subdomain ends up serving up the empty page. This works because alphabetically the IP address occurs before any alphabetic site.

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