Open vortegatorres opened 4 months ago
@vortegatorres
upstream_status
is set at apisix.http_balancer_phase
, but
`serverless-pre-function @ rewrite phase returning 401(>=200, for more to see below) will interrupt that flow.
If you want to modify the response from upstream, try serverless-xxx @ [header | body]_filter phase.
core.response.exit(401) -> ngx.exit(401)
restydoc -s ngx.exit
When "status >= 200" (i.e., "ngx.HTTP_OK" and above), it will interrupt
the execution of the current request and return status code to Nginx.
...
@vortegatorres
upstream_status
is set atapisix.http_balancer_phase
, but `serverless-pre-function @ rewrite phase returning 401(>=200, for more to see below) will interrupt that flow.If you want to modify the response from upstream, try serverless-xxx @ [header | body]_filter phase.
core.response.exit(401) -> ngx.exit(401) restydoc -s ngx.exit When "status >= 200" (i.e., "ngx.HTTP_OK" and above), it will interrupt the execution of the current request and return status code to Nginx. ...
If I understand correctly, the [header|body]_filter phases modify the upstream response. In my case, I use the serverless-pre-function
plugin to be called from the forward-auth
plugin, and there is no upstream body to modify, and your suggestion didn't work. Is there a workaround for setting the upstream_status
in this scenario?
@vortegatorres
upstream_status
is set atapisix.http_balancer_phase
, but `serverless-pre-function @ rewrite phase returning 401(>=200, for more to see below) will interrupt that flow. If you want to modify the response from upstream, try serverless-xxx @ [header | body]_filter phase.core.response.exit(401) -> ngx.exit(401) restydoc -s ngx.exit When "status >= 200" (i.e., "ngx.HTTP_OK" and above), it will interrupt the execution of the current request and return status code to Nginx. ...
If I understand correctly, the [header|body]_filter phases modify the upstream response. In my case, I use the
serverless-pre-function
plugin to be called from theforward-auth
plugin, and there is no upstream body to modify, and your suggestion didn't work. Is there a workaround for setting theupstream_status
in this scenario?
Could you show the route/plugins config more similar with your scenario?
@vortegatorres
upstream_status
is set atapisix.http_balancer_phase
, but `serverless-pre-function @ rewrite phase returning 401(>=200, for more to see below) will interrupt that flow. If you want to modify the response from upstream, try serverless-xxx @ [header | body]_filter phase.core.response.exit(401) -> ngx.exit(401) restydoc -s ngx.exit When "status >= 200" (i.e., "ngx.HTTP_OK" and above), it will interrupt the execution of the current request and return status code to Nginx. ...
If I understand correctly, the [header|body]_filter phases modify the upstream response. In my case, I use the
serverless-pre-function
plugin to be called from theforward-auth
plugin, and there is no upstream body to modify, and your suggestion didn't work. Is there a workaround for setting theupstream_status
in this scenario?Could you show the route/plugins config more similar with your scenario?
I have a route that is authenticated using the forward-auth
plugin pointing to another route using serverless-pre-function
plugin:
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
name: service
namespace: service
spec:
http:
- name: service
match:
paths:
- "/service"
backends:
- serviceName: service
servicePort: 10001
plugins:
- name: auth
enable: true
config:
uri: "http://127.0.0.1:9080/auth"
- name: schemas
match:
paths:
- "/service"
apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
name: auth
spec:
http:
- name: auth
match:
paths:
- "/auth"
plugins:
- name: serverless-pre-function
enable: true
config:
phase: rewrite
functions:
- return function(conf, ctx)
local core = require("apisix.core");
core.response.exit(401);
Is there any update on this issue?
Current Behavior
After executing the
serverless-pre-function
plugin with a Lua script that modifies the response, theupstream_status
value is empty. This leads to issues such as an incorrect http_status attribute in the span when the OpenTelemetry plugin is executed, as it relies on the upstream_status value.Expected Behavior
Ensure
upstream_status
retains a correct value after executing a Lua script that calls thecore.response.exit()
function.Error Logs
Steps to Reproduce
upstream_status
by including it in thenginx_config.http.access_log_format.
serverless-pre-function
plugin that modifies the response status code:upstream_status
is empty.Environment
apisix version
): 3.7.0uname -a
): x86_64 GNU/Linuxopenresty -V
ornginx -V
): nginx version: openresty/1.21.4.2curl http://127.0.0.1:9090/v1/server_info
): etcd-8.7.7