Submitted by moimichel on Mon, 01/31/2011 - 16:03
I would like to deny access to the default server on apache. Only want to allow the virtual servers. Example: I want to disable access to a request with a sub domain like server1.mydomain.com (because server1.mydomain.com is not a web server but a simplya name of a machine). But by default apache will interpret that sub domain as adefault server and serve pages from /var/www directory. How can I disable that?
Thanks in advance.
Status:
Active
Comments
Submitted by andreychek on Mon, 01/31/2011 - 16:12 Comment #1
Howdy -- it sounds like what you may want is to setup a Virtual Server that can act as a default page... but one that's served out of /home rather than /var/www.
If you setup a new Virtual Server, you can set it up as the default website for your server by going into Server Configuration -> Website Options, and setting "Default website for IP address" to "Yes".
Will that do what you're after?
Submitted by abraham on Tue, 03/10/2020 - 08:06 Comment #2
I dont want it to use my virtual server as default website and in website option NO option is disabled. ANY IDEA?
Apache has global options for
LISTEN
,DocumentRoot
,<Directory></Directory>
,AssignUserId
and many other, that affect default response for servers that are not registered as part of<VirtualHost></VirtualHost>
. There are plenty of discussions about that. It's something you should figure out yourself, besides it's not difficult at all, just start picking it.Submitted by JamieCameron on Thu, 03/12/2020 - 00:26 Comment #4
Unfortunately there is no way to prevent Apache from serving some content when a domain with no website is opened in a browser. The suggesting in comment #1 is the way to go - just create a blank website and make it the default.
Submitted by abraham on Thu, 03/12/2020 - 02:17 Comment #5
actually I want to use my IP and redirect it to some other directory using trailing slash and because the empty server only redirects to its own folder. I want to point my IP to "/home" directory because the directory I want to point is there so when I was to use my IP I can do IPAddress/somedirectory to point to my website but due to this issue when I create empty server it create and points to /home/server which I don't want. in earlier version of virtual min this was not an issue :/
Unless we are talking about completely different setups, I'm personally convinced that it's possible, and here is how!
Example
Question 1: What happens if you visit dom2? It will fall to dom1. What happens if you visit dom3 - it will go to _default_ and look for index-2.html from /var/www/html.
Question 2: How to make dom2 not to use dom1 default website DocumentRoot? Simply by registering dummy VirtualHost with no particular ServerName directive for the same IP, and before any VirtualHost declaration for this IP:
In both examples we registered defaults. :) Moving directive up and down also works, and hitting the first VirtualHost makes it global default but it's not always what you might want.