Inheritance of config directives looks not straightforward, there is a lot of cases where we can't predict how configuration file will be interpreted by Tempesta FW. Especially this applies to default vhost.
For example, this simple config has unpredictable behavior in two places:
Just looking on config we can assume following behavior: 1. When request is routed to tempesta-tech vhost response must have two headers added by Tempesta: hdr: global and hdr: tempesta-tech, however that's not how it works now. In this case we received only hdr: tempesta-tech, this is bug. But when request is routed to default vhost Tempesta responds with two headers: hdr: global and hdr: default as expected. Although resp_hdr_add works as expected, it looks like bug also, why different inheritance rules applied to same directive that located in two different vhosts vhost tempesta-tech.com and vhost defualt?
Here we have cache_fulfill * * in global scope and overriding cache_fulfill prefix "/must_cache"; in both vhosts, but behavior for vhosts will be different. If request is forwarded to vhost default any uri will be received from cache, it means cache_fulfill * *; will be applied to default vhost. If request is forwarded to vhost tempesta-tech.com only request with uri /must_cache will be processed from cache, global cache_fulfill * *; will be completely ignored.
Summary: vhost default and other vhosts have different inheritance principles that not straightforward, some of directives from global scope not extends but overrides in vhosts, that also looks unpredictable. For overriding we can use approach suggested in this comment.
Scope
Inheritance of config directives looks not straightforward, there is a lot of cases where we can't predict how configuration file will be interpreted by Tempesta FW. Especially this applies to
default
vhost.For example, this simple config has unpredictable behavior in two places:
Just looking on config we can assume following behavior: 1. When request is routed to
tempesta-tech
vhost response must have two headers added by Tempesta:hdr: global
andhdr: tempesta-tech
, however that's not how it works now. In this case we received onlyhdr: tempesta-tech
, this is bug. But when request is routed todefault
vhost Tempesta responds with two headers:hdr: global
andhdr: default
as expected. Althoughresp_hdr_add
works as expected, it looks like bug also, why different inheritance rules applied to same directive that located in two different vhostsvhost tempesta-tech.com
andvhost defualt
?Here we have
cache_fulfill * *
in global scope and overridingcache_fulfill prefix "/must_cache";
in both vhosts, but behavior for vhosts will be different. If request is forwarded tovhost default
any uri will be received from cache, it meanscache_fulfill * *;
will be applied todefault
vhost. If request is forwarded tovhost tempesta-tech.com
only request with uri/must_cache
will be processed from cache, globalcache_fulfill * *;
will be completely ignored.Summary:
vhost default
and other vhosts have different inheritance principles that not straightforward, some of directives from global scope not extends but overrides in vhosts, that also looks unpredictable. For overriding we can use approach suggested in this comment.