3

I have 5 virtual hosts in httpd.conf. All of them have the configuration below except for one.

<Location />
    Order Deny,Allow
    Deny from all
    Allow from IP.ADDRESS.GOES.HERE
</Location>

I think it would be better to tell all virtual hosts to have this except for one. Currently, I am telling each virtual host one by one to have this. Is there a wild card method to apply this setting to all virtual hosts and then remove this stanza from one of the virtual hosts in httpd.conf?

4

Yes, you can define your global <Location> in the main apache configuration, before your <Virtualhost> directives and then override it with the same <Location> inside one of your virtualhosts.

<Location />
    # some directives
</Location>

<Virtualhost *:80>
    <Location />
        # some other directives
    </Location>
<Virtualhost>

See https://httpd.apache.org/docs/current/mod/core.html#location and https://httpd.apache.org/docs/current/mod/directive-dict.html#Context for more - the reason this works is because <Location> is valid in both the "server config" and "virtual host" contexts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy