Welcome! Log In Create A New Profile

Advanced

Elegant way to inject IP filtering in vhosts

Posted by nginy 
Elegant way to inject IP filtering in vhosts
August 25, 2018 01:57PM
Have a dozen of vhosts which sometime require IP filtering (maintenance ...) using 'geo'.

So

- 'geo' is in http context, and gives a variable a value depending on the IP filters => that declaration is in an include file "Geo"

- then have a 'error_page / location / rewrite / if / return' block => is in an include file "IP_filter"

To activate filtering, "include Geo;" is added in 'http', and "include IP_filter;" is injected in each 'server'

That's only 1 + N vhosts lines to add, but I was wondering if there is a more elegant way to inject the filtering into each 'server' (without modifying the files each time), like a "trick" in the 'http' block(?).

Of course I could include the same empty file "Injection" into each 'server', and only fill that file with a nested "include IP_filter" and reload the config, when necessary. But that doesn't seem very clean (to me at least).

Any suggestion is welcome.

Thank you.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 75
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready