You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Ronald F. Guilmette" <rf...@tristatelogic.com> on 2016/09/12 01:43:55 UTC

[users@httpd] 2.4 named virtual hosts question

A simple question.  Sorry if this is an FAQ.

I'm just bringing up a fresh VM system that I plan to move my small
handful of web sites to.

I'v so far managed to mostly get apache24 installed and configured.
I've moved all of my web sites over to the new system, and it mostly
all seems to be working, but I ran the "httpd -S" command to see
if that would detect any goof-ups on my part.  (It did, but I already
fixed those.)

Now when I run "httpd -S" I am seeing in the output:

===============================================================================
VirtualHost configuration:
*:*                    is a NameVirtualHost
         default server tristatelogic.com (/usr/local/etc/apache24/extra/httpd-vhosts.conf:40)
         port * namevhost tristatelogic.com (/usr/local/etc/apache24/extra/httpd-vhosts.conf:40)
                 alias www.tristatelogic.com
         port * namevhost 47-usc-230c2.org (/usr/local/etc/apache24/extra/httpd-vhosts.conf:69)
                 alias www.47-usc-230c2.org
         port * namevhost sordid-details.com (/usr/local/etc/apache24/extra/httpd-vhosts.conf:94)
                 alias www.sordid-details.com
...
===============================================================================

I have three domains that I want to serve (as vhosts) from this newly
installed server, and all three are mentioned above.  But the part I don't
get (and don't really want) is all that stuff about a default (*:*)
server/service.  How can I get rid of that while still providing service
for my three vhosts?

(Note:  People may say: "Oh, just leave it.  It isn't really any
problem to just leave it."  But I'm paranoid about security, so I'm
always inclined to minimize my attack surface as much as possible.)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 2.4 named virtual hosts question

Posted by Rainer Canavan <ra...@sevenval.com>.
On Mon, Sep 12, 2016 at 7:37 PM, Marat Khalili <mk...@rqc.ru> wrote:
> On 12/09/16 18:47, Rainer Canavan wrote:
>> The obvious ones I can come up with would be Alias, ScriptAlias,
>> FastCGIExternalServer,
>> Action and RewriteRule. All those can be defined in the global context
>> (i.e. outside
>> of any vhost) and are valid for all vhosts. (for RewriteRule, that may
>> require
>> RewriteOptions Inherit), all others simply apply to all vhosts.
>
> But if I remove my default "deny" virtual host, what changes? That's what I
> cannot quite get in your explanation.

If you remove the special "deny" vhost, everything is fine. If you add one,
you may have set yourself  a much larger set of traps than the configuration
options  I've listed above.

rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 2.4 named virtual hosts question

Posted by Marat Khalili <mk...@rqc.ru>.
On 12/09/16 18:47, Rainer Canavan wrote:
>
> The obvious ones I can come up with would be Alias, ScriptAlias,
> FastCGIExternalServer,
> Action and RewriteRule. All those can be defined in the global context
> (i.e. outside
> of any vhost) and are valid for all vhosts. (for RewriteRule, that may require
> RewriteOptions Inherit), all others simply apply to all vhosts.
But if I remove my default "deny" virtual host, what changes? That's 
what I cannot quite get in your explanation.

-- 

With Best Regards,
Marat Khalili

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 2.4 named virtual hosts question

Posted by Rainer Canavan <ra...@sevenval.com>.
On Mon, Sep 12, 2016 at 3:21 PM, Marat Khalili <mk...@rqc.ru> wrote:
> On 12/09/16 15:25, Rainer Canavan wrote:
>>
>>
>> However, in this example, you'd add a virtualhost that may expose
>> globally configured resources without the individual access controls of
>> the "real" vhosts. On top of that, the additional vhost may not see any
>> significant testing in case of configuration changes.
>
> I don't get it, can you please provide an example? IMO any additional vhosts
> should not depend at all on what's inside this vhost.

The obvious ones I can come up with would be Alias, ScriptAlias,
FastCGIExternalServer,
Action and RewriteRule. All those can be defined in the global context
(i.e. outside
of any vhost) and are valid for all vhosts. (for RewriteRule, that may require
RewriteOptions Inherit), all others simply apply to all vhosts.

>> Do _exactly_ that, e.g. with a RewriteRule to - and RewriteCond that
>> checks the Host: header.
>
> You mean, outside any virtualhost? Why do you think it's better? Initial
> problem was default virtualhost -- I want none.

that's exaclty what I'm saying. A default vhost has the potential to add
more problems than it can ever solve.

[...]

>> Overall I'd say that the negligible gain in
>> perceived security isn't worth the effort or the additional risks
>> (both regarding security and availability).
>
> Well, for one thing log messages from actual vhosts and from internet scans
> are separated, this alone saves a lot of time.

Finally, an actual, measurable benefit, although it only filters out the
not-too-smart scanners.

rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 2.4 named virtual hosts question

Posted by Marat Khalili <mk...@rqc.ru>.
On 12/09/16 15:25, Rainer Canavan wrote:
>
> However, in this example, you'd add a virtualhost that may expose
> globally configured resources without the individual access controls of
> the "real" vhosts. On top of that, the additional vhost may not see any
> significant testing in case of configuration changes.
I don't get it, can you please provide an example? IMO any additional 
vhosts should not depend at all on what's inside this vhost.

>
> Do _exactly_ that, e.g. with a RewriteRule to - and RewriteCond that
> checks the Host: header.
You mean, outside any virtualhost? Why do you think it's better? Initial 
problem was default virtualhost -- I want none. Your method only 
protects from absence of Host header, not from incorrect Host header, 
SNI etc. IMO presupposing Apache vhost selection is bad solution here.

> If you're really serious, you'd also have to make sure that any error messages
> don't contain the hostname, and you'd have to set reverse DNS lookups to
> point to a useless name.
I did.

> Overall I'd say that the negligible gain in
> perceived security isn't worth the effort or the additional risks
> (both regarding security and availability).
Well, for one thing log messages from actual vhosts and from internet 
scans are separated, this alone saves a lot of time.

--

With Best Regards,
Marat Khalili

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 2.4 named virtual hosts question

Posted by Rainer Canavan <ra...@sevenval.com>.
[...]

>> Additionally, if you bind any further vhosts to specific IP addresses, e.g.
>> <VirtualHost 192.0.2.1:80>, then that virtualhost will have precedence for
>> requests to 192.0.2.1:80 over the *:80 virtualhost.
>
> In this case you'll have create separate default deny configuration for each
> IP address, right?
>
>> Overall, I'd say that such a construct is more likely to increase the attack surface
>> instead of reducing it.
>
> I don't think _denying_ something can _increase_ attack surface.

However, in this example, you'd add a virtualhost that may expose
globally configured resources without the individual access controls of
the "real" vhosts. On top of that, the additional vhost may not see any
significant testing in case of configuration changes.

> But since
> there's seemingly demand for this kind of configuration it'd be nice if
> community helped make it better and more secure. What extra steps do you
> think one should take to securely deny (and subsequently ban) clients
> (mostly bots) that do not even know domain name they are accessing?

Do _exactly_ that, e.g. with a RewriteRule to - and RewriteCond that
checks the Host: header. I'd guess that httpd 2.4 has more elegant means
to express this with actual "deny" directives, possibly combined with a
SetEnvIf.

If you're really serious, you'd also have to make sure that any error messages
don't contain the hostname, and you'd have to set reverse DNS lookups to
point to a useless name. Overall I'd say that the negligible gain in
perceived security isn't worth the effort or the additional risks
(both regarding
security and availability).

rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 2.4 named virtual hosts question

Posted by Marat Khalili <mk...@rqc.ru>.
On 12/09/16 12:03, Rainer Canavan wrote:

> I'm not 100% sure, but that may not deny access to absolutely 
> everything, in case you have global
> directives such as cgi aliases or proxy constructs, possibly with 
> mod_rewrite and [P] which point
> to non-directory resources.
>
> Therefore it may be better to use <Location> instead of <Directory>.
Thanks for noticing! Of course all other directives are supposed to be 
within virtualhosts, but worth changing just to be extra sure.

> Additionally, if you bind any further vhosts to specific IP addresses, 
> e.g.
> <VirtualHost 192.0.2.1:80 <http://192.0.2.1:80>>, then that 
> virtualhost will have precedence for
> requests to 192.0.2.1:80 <http://192.0.2.1:80> over the *:80 virtualhost.
In this case you'll have create separate default deny configuration for 
each IP address, right?

> Overall, I'd say that such a construct is more likely to increase the 
> attack surface
> instead of reducing it.
I don't think _denying_ something can _increase_ attack surface. But 
since there's seemingly demand for this kind of configuration it'd be 
nice if community helped make it better and more secure. What extra 
steps do you think one should take to securely deny (and subsequently 
ban) clients (mostly bots) that do not even know domain name they are 
accessing?

--

With Best Regards,
Marat Khalili


Re: [users@httpd] 2.4 named virtual hosts question

Posted by Rainer Canavan <ra...@sevenval.com>.
>> <VirtualHost *:80>
>>     ServerName default
>>
>>     <Directory />
>>         AllowOverride none
>>         Order Allow,Deny
>>         Require all denied
>>     </Directory>
>> </VirtualHost>
[...]

I'm not 100% sure, but that may not deny access to absolutely everything,
in case you have global
directives such as cgi aliases or proxy constructs, possibly with
mod_rewrite and [P] which point
to non-directory resources.

Therefore it may be better to use <Location> instead of <Directory>.

Additionally, if you bind any further vhosts to specific IP addresses, e.g.
<VirtualHost 192.0.2.1:80>, then that virtualhost will have precedence for
requests to 192.0.2.1:80 over the *:80 virtualhost.

Overall, I'd say that such a construct is more likely to increase the
attack surface
instead of reducing it.

rainer

Re: [users@httpd] 2.4 named virtual hosts question

Posted by Marat Khalili <mk...@rqc.ru>.
There has to be some configuration Apache will use if it cannot match 
any virtualhost; or, if no hostname is specified by client. You can make 
a configuration that denies access in this case, and put it before 
others. That's what I use:

> <VirtualHost *:80>
>     ServerName default
>
>     <Directory />
>         AllowOverride none
>         Order Allow,Deny
>         Require all denied
>     </Directory>
> </VirtualHost>
>
> SSLStrictSNIVHostCheck on
> <VirtualHost *:443>
>     ServerName default
>
>     SSLEngine on
>     SSLCertificateFile  /etc/ssl/certs/ssl-cert-snakeoil.pem
>     SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
>     <Directory />
>         AllowOverride none
>         Order Allow,Deny
>         Require all denied
>     </Directory>
> </VirtualHost>
Works great in pair with fail2ban ;)

--

With Best Regards,
Marat Khalili

On 12/09/16 04:43, Ronald F. Guilmette wrote:
> A simple question.  Sorry if this is an FAQ.
>
> I'm just bringing up a fresh VM system that I plan to move my small
> handful of web sites to.
>
> I'v so far managed to mostly get apache24 installed and configured.
> I've moved all of my web sites over to the new system, and it mostly
> all seems to be working, but I ran the "httpd -S" command to see
> if that would detect any goof-ups on my part.  (It did, but I already
> fixed those.)
>
> Now when I run "httpd -S" I am seeing in the output:
>
> ===============================================================================
> VirtualHost configuration:
> *:*                    is a NameVirtualHost
>           default server tristatelogic.com (/usr/local/etc/apache24/extra/httpd-vhosts.conf:40)
>           port * namevhost tristatelogic.com (/usr/local/etc/apache24/extra/httpd-vhosts.conf:40)
>                   alias www.tristatelogic.com
>           port * namevhost 47-usc-230c2.org (/usr/local/etc/apache24/extra/httpd-vhosts.conf:69)
>                   alias www.47-usc-230c2.org
>           port * namevhost sordid-details.com (/usr/local/etc/apache24/extra/httpd-vhosts.conf:94)
>                   alias www.sordid-details.com
> ...
> ===============================================================================
>
> I have three domains that I want to serve (as vhosts) from this newly
> installed server, and all three are mentioned above.  But the part I don't
> get (and don't really want) is all that stuff about a default (*:*)
> server/service.  How can I get rid of that while still providing service
> for my three vhosts?
>
> (Note:  People may say: "Oh, just leave it.  It isn't really any
> problem to just leave it."  But I'm paranoid about security, so I'm
> always inclined to minimize my attack surface as much as possible.)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 2.4 named virtual hosts question

Posted by Eric Covener <co...@gmail.com>.
On Sun, Sep 11, 2016 at 10:00 PM, Ronald F. Guilmette
<rf...@tristatelogic.com> wrote:
>>The first one will always be a default. You can make a dedicated one for it.
>
> Thank you.  I appreciate your timely reply, however I think that maybe
> you didn't quite get my point and/or my question.
>
> I simply do not want there to exist a default vhost, period.
>
> Isn't there any magic directive like "SetDefaultVhost none" or some
> such thing like that?

Nothing like that.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 2.4 named virtual hosts question

Posted by Jim Walls <ji...@k6ccc.org>.
On 9/11/2016 19:00, Ronald F. Guilmette wrote:
> Eric Covener <co...@gmail.com> wrote:
>
>> The first one will always be a default. You can make a dedicated one for it.
> Thank you.  I appreciate your timely reply, however I think that maybe
> you didn't quite get my point and/or my question.
>
> I simply do not want there to exist a default vhost, period.
>
> Isn't there any magic directive like "SetDefaultVhost none" or some
> such thing like that?

Not that I've ever heard of.  Keep in mind that the only time someone 
should get to the default is if they point to the IP rather than a 
domain, or there is a DNS problem somewhere that is pointing some other 
domain to your IP address.  You could just have a simple page that 
advises that there was an error.

-- 
73
-------------------------------------
Jim Walls - K6CCC
jim@k6ccc.org
Ofc:  818-548-4804
http://members.dslextreme.com/users/k6ccc/
AMSAT Member 32537 - WSWSS Member 395



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 2.4 named virtual hosts question

Posted by "Ronald F. Guilmette" <rf...@tristatelogic.com>.
Eric Covener <co...@gmail.com> wrote:

>The first one will always be a default. You can make a dedicated one for it.

Thank you.  I appreciate your timely reply, however I think that maybe
you didn't quite get my point and/or my question.

I simply do not want there to exist a default vhost, period.

Isn't there any magic directive like "SetDefaultVhost none" or some
such thing like that?

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] 2.4 named virtual hosts question

Posted by Eric Covener <co...@gmail.com>.
On Sun, Sep 11, 2016 at 9:43 PM, Ronald F. Guilmette
<rf...@tristatelogic.com> wrote:
> How can I get rid of that while still providing service
> for my three vhosts?


The first one will always be a default. You can make a dedicated one for it.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org