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?

0 Answers0