nginx proxy_pass check upstream content type
Asked Answered
D

0

6

I want to give a simple 403 forbidden error if source server return application/vnd.error+json for content type. Here is my code:

server {
root /var/www/;
recursive_error_pages on;
        location / {
            proxy_pass                      "http://source";
            proxy_set_header Host           "source";
            proxy_pass_request_headers      on;
            proxy_intercept_errors          on;
            if ($upstream_http_content_type = "application/vnd.error+json" ) {
              return 403;
            }
        }       
}

But it dont returns me 403 error. It returns the source server's content. How can I modify status code, headers and body which sent to client?

Desired answered 27/10, 2016 at 4:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.