which is working flawlessly for each one of my sites.
Then I’m trying with another snippet of some code that I always repeat for my proxy directives:
(proxy_options) {
transparent
# Enable HTTP Strict Transport Security (HSTS) to force clients to always
# connect via HTTPS (do not use if only testing)
header_downstream Strict-Transport-Security "max-age=31536000;"
# Enable cross-site filter (XSS) and tell browser to block detected attacks
header_downstream X-XSS-Protection "1; mode=block"
# Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
header_downstream X-Content-Type-Options "nosniff"
# Disallow the site to be rendered within a frame (clickjacking protection)
header_downstream X-Frame-Options "DENY"
}
Snippets can’t be used within directives, so that’s probably why you’re getting that error. If you bring the whole directive into the snippet, it will be more useful for you!
So in a case like that, where a directive may have several parameters but the first line specifies different addresses cannot be shortened using this facility? I guess this rather severely limits its use.
My understanding is that each directive is parsed by its own setup function, which would make importing inside a directive impossible unless that directive implemented its own import subdirective; it would be like trying to rewrite inside a log directive, or something.
I confess I would have thought it actually simpler to make it a simple text replacement macro, with the parsing following on. But I realise there might be reasons for this not to be so obvious.
I agree with @pwhodges than if snippets can’t be used inside directives like proxy then the feature is a bit limited. Anyway, it’s a nice addition. I hope the functionality can be extended in the future.