[Django]-Set Custom Header in Nginx config and pass it to gunicorn

4👍

The primary problem is that proxy_set_header directives are not allowed in the if block.

However, the same functionality can be accomplished using a map directive. Using the following within the http block:

map $mobile_rewrite $render_mobile_rewrite {
    default     0;
    perform     1;
}

And the following in your existing location block:

proxy_set_header renderMobileWebsite $render_mobile_rewrite;

See this document for details.

Leave a comment