nginx-vod-module icon indicating copy to clipboard operation
nginx-vod-module copied to clipboard

error_page not working when upstream returns an error on remote mode

Open idanya opened this issue 2 years ago • 1 comments

When working on remote mode (vod_mode remote;) and the upstream returns code other than 200/206, the client gets 502. The source of it is probably here

I have some authorization and rate-limiting implementation on the upstream that I want to make visible to the CDN and client. I've tried to use the following error_page directive in order to override the 502 response, with no luck:

error_page 502 = @location;

location @location {                           
  more_set_headers 'Access-Control-Allow-Origin: *';        
  more_set_headers 'Cache-Control: public, max-age=3600, immutable';
  more_set_headers 'Timing-Allow-Origin: *';  
  more_set_headers 'Content-Type: text/plain';
  return 403 "Forbidden";
}   

Seems like the error_page directive is ignored and I still get 502 on the client-side.

I understood from browsing in other issues that supporting upstream return codes are a low priority and is not planned. Is there a workaround for this issue? any other wrapper than error_page? Or maybe a way to make the error_page work?

idanya avatar Feb 09 '22 14:02 idanya

Try: error_page 502 =403 @location;

phillipseamore avatar Feb 19 '22 15:02 phillipseamore