Q: Disable access to default vhost and through server IP on Apache 2.4.10 -


i'm trying apache 2.4.10 on debian 8 "jessie" , running multiple websites hosted on it. might obvious , answered question i've never had need set-up dedicated web host (usually drop wamp server development needs or pick web hosting service) , far have not had luck finding answer problem (i've found complete opposite answers of i'm trying achieve). need working because apart hosting couple of websites, there additional software set-up, which, regular web hosting service won't do.

everything seems working intended problem can't seem find optimal configuration wouldn't block access default vhost 403 - forbidden. need apache ignore requests (not return 404 document tell browser there's nothing there) accessing default vhost or accessing server directly through it's designated ip. designated ip should left ssh access (since don't have kind of physical access server).

basically, web server should accessible web browser through "fqdn-1" , "fqdn-2" (each located in individual directories) , access other web address on server should ignored (invoking browser "404 not found" instead of returning server error document, indicate there).

my current vhost files:

<virtualhost *:80>     servername fqdn-1     serveralias www.fqdn-1     serveradmin mail@fqdn-1     documentroot /var/www/fqdn-1/public_html     errorlog /var/www/fqdn-1/logs/error.log     customlog /var/www/fqdn-1/logs/access.log combined </virtualhost> 

and

<virtualhost *:80>         servername fqdn-2         serveralias www.fqdn-2         serveradmin mail@fqdn-2         documentroot /var/www/fqdn-2/public_html         errorlog /var/www/fqdn-2/logs/error.log         customlog /var/www/fqdn-2/logs/access.log combined </virtualhost> 

the default vhost has been disabled through "a2dissite 000-default"
iptables block except tcp port 80 , 22 (ssh access whitelisted in iptables few specific ips).

you can let built-in name-based vhosting work you. can setup additional (non default / non-first listed *:80) virtualhost

servername your-ip  

and put simple rule

rewriteengine on  rewriterule ^ .* [f] 

or

redirect 403 / 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -