response-rewrite
This Plugin can be useful in these scenarios:
- To set custom
status_code
andLocation
fields in the header to redirect.
tip
You can also use the redirect Plugin to setup redirects.
note
Only one of body
or can be configured.
Here, vars
is configured to run the Plugin only on responses with a 200 status code.
Once you have enabled the Plugin as shown above, you can make a request:
The response will be as shown below no matter what the response is from the Upstream:
IMPORTANT
However, if ngx.exit
is executed during an access phase, it will only interrupt the request processing phase and the response phase will still continue to run.
So, if you have configured the response-rewrite
Plugin, it do a force overwrite of the response.