Default 403 response when no matching vhost

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Default 403 response when no matching vhost

Danny Mallory
Figure I would ask this here for the most graceful answer before making up my own.  When running Apache for many vhosts (websites or acting as a reverse proxy), is there a way to make the default site (no matching vhost) return a 403 or 400 bad request similar to how Akamai does when no matching vhost is found. Currently I have a default site that just returns the standard "It works" 200 ok when no match is found..

SNIP: 
dig www.microsoft.com +short
23.66.54.52 (Akamai)

curl -kv 23.66.54.52
< HTTP/1.0 400 Bad Request
< Server: AkamaiGHost

thx in advance

Danny 
Reply | Threaded
Open this post in threaded view
|

Re: Default 403 response when no matching vhost

Eric Covener
On Mon, Jul 13, 2020 at 1:02 PM Danny Mallory <[hidden email]> wrote:
>
> Figure I would ask this here for the most graceful answer before making up my own.  When running Apache for many vhosts (websites or acting as a reverse proxy), is there a way to make the default site (no matching vhost) return a 403 or 400 bad request similar to how Akamai does when no matching vhost is found. Currently I have a default site that just returns the standard "It works" 200 ok when no match is found..

You can use mod_asis which is pretty obscure, or RewriteRule ^ =
[R=4xx] (it accepts non-redirect codes and mostly works)
Or for 403, you could have a `require all denied` block in the vhost
for <Location />

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Default 403 response when no matching vhost

Danny Mallory
Appreciate the feedback. Rewrite was certainly my first choice and allows me to exclude paths. 


Danny


-------- Original message --------
From: Eric Covener <[hidden email]>
Date: 7/13/20 12:39 PM (GMT-06:00)
Subject: Re: [users@httpd] Default 403 response when no matching vhost

On Mon, Jul 13, 2020 at 1:02 PM Danny Mallory <[hidden email]> wrote:
>
> Figure I would ask this here for the most graceful answer before making up my own.  When running Apache for many vhosts (websites or acting as a reverse proxy), is there a way to make the default site (no matching vhost) return a 403 or 400 bad request similar to how Akamai does when no matching vhost is found. Currently I have a default site that just returns the standard "It works" 200 ok when no match is found..

You can use mod_asis which is pretty obscure, or RewriteRule ^ =
[R=4xx] (it accepts non-redirect codes and mostly works)
Or for 403, you could have a `require all denied` block in the vhost
for <Location />

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]