homepage Welcome to WebmasterWorld Guest from 174.129.163.183
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Make IP based virtual host respond only to request for it domain name
Make IP based virtual host respond only to request for it domain name
Guilder




msg:4391451
 1:54 pm on Nov 27, 2011 (gmt 0)

I'd like my single virtual host to respond only to requests for it's configured domain. Not for requests for the server IP

/etc/apache2/sites-enabled/mydomain looks like this:

<VirtualHost 172.0.0.1:80>
ServerName www.mydomain.co.uk
ServerAlias mydomain.co.uk
DocumentRoot /var/www/mydomain
</VirtualHost>

<VirtualHost 172.0.0.1:443>
ServerName www.mydomain.co.uk
ServerAlias mydomain.co.uk
DocumentRoot /var/www/mydomain
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/ssl.crt/www.mydomain.co.uk.crt
SSLCertificateKeyFile /etc/apache2/ssl/ssl.key/www.mydomain.co.uk.key
</VirtualHost>


It means that HTTP and HTTPS works for www.mydomain.co.uk reolving to 172.0.0.1
The virtual hsot has to be IP based to support SSL.

* how do I stop requests to h tt p://172.0.0.1 returning the website? More specificaly, how do I make the virtual host *only* respond to requests for www.mydomain.co.uk?

I also have a new domain, www.my2nddomain.co.uk. I've setup an A record resolving www.my2nddomain.co.uk to 172.0.0.1 (same IP as above). Requests for www.my2nddomain.co.uk return my www.mydomain.co.uk website. Again, another situation where the virtual host needs to respond only to requests for www.mydomain.co.uk.

All help appreciated!

 

bhukkel




msg:4391461
 3:08 pm on Nov 27, 2011 (gmt 0)

The first virtual host you define is the default virtual host and response to every request. So you could make a dummy virtual host as the first one with a blank page and the second virtual host with the domain you want.

Perhaps this helps?

lucy24




msg:4391507
 8:25 pm on Nov 27, 2011 (gmt 0)

how do I stop requests to 172.0.0.1 returning the website?

What do you want them to do instead? Blank page, alternate page, redirect to named site? There are probably a couple of other options. The address exists, so you can't say "ain't no such place", though you might find the Internet equivalent of "go around the back" or "please use the service entrance".

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved