Setting a custom header based on another upstream/sent header

Reinis Rozitis r at
Thu Aug 22 12:26:12 UTC 2019

> Is this expected behaviour? Could there be another way to do this?

'if' (the rewrite module) is executed in early stages when $sent_* variables are not available that’s why the regex doesn't match.

What you could do is use 'map' instead:
( )

map $sent_http_link $IS_WORDPRESS  {
   ~*.*wp-json.* "true";
    default "false";

And then:

add_header                    X-Is-WordPress $IS_WORDPRESS;


More information about the nginx mailing list