Open tony-liuliu opened 4 years ago
We don't have generic rewrite functionality currently. This could be implemented by a custom filter or Lua potentially.
@mattklein123 Thank you very much, I will try to use custom filter. Is there a similar custom filter example.
@tony-liuliu do you think you can make it available upstream? Thinking to have a way to modify the proxied response (with non-2xx status), do you think it makes sense to have an error_page
"filter" similar to what NGINX has? (in NGINX, we need to turn on proxy_intercept_errors
to let non-2xx proxied response to be handled by the proxy's error_page
config).
I can see it can also be implemented in Lua (with some thinking on how to not complicate the "state management" there). Relevant: https://github.com/envoyproxy/envoy/issues/5998.
Yes, I think this feature is very useful because our back-end services are provided by different languages, such as nginx, tomcat, nodejs, go. If you do not manually compile and configure them, their server information will expose it when an error is encountered, which is prone to insecure factors. Using proxy_intercept_errors like nginx to unify redirect errors seems very suitable for this scenario. This way we don't have to modify error redirects such as http 404 for each backend language. I hope that envoy can consider such needs in future plans.
@tony-liuliu if you can help us with a design doc, I think I can help you with the implementation.
cc. @mattklein123
I think it would be great to have a custom response encoder filter that could do something like this.
Note also this would go really well with the work outlined here to allow for response matching: https://github.com/envoyproxy/envoy/issues/12968. cc @snowp
I tried to do something similar with an AssemblyScript WASM filter and failed.
My filter's onResponseHeaders() could see the 4xx/5xx returned by the backend. I tried calling send_local_response()
from within onResponseHeaders() but by then it was too late.
I notice FilterHeadersStatus .ContinueAndDontEndStream was recently added which might solve my problem but that return isn't yet available in the Envoy version I am using nor in the Solo.io AssemblyScript runtime.
@dio @mattklein123 Is this sufficient for a design doc? https://docs.google.com/document/d/1Bgi0agddua9LyBH3NnGBuDPcYJxoZwZLnL1rBcKFgZI
This behavior should be implemented as a filter. It's not clear to me that is what is being proposed? Is it?
I ended up implementing this as an HTTP filter before I knew this issue (or any design documents/requirements) existed. For that reason, my approach may be different than what's being discussed here but I'm very much open to feedback. Please see https://github.com/envoyproxy/envoy/pull/14221 ( cc @mattklein123 / @tony-liuliu )
This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.
Let's move this to no stalebot
. I'm tracking an implementation in https://github.com/envoyproxy/envoy/pull/14221 but it fell to the backburner during the holidays + other tasks. I'll be looking at it again soon, though.
Are there implementation plans for this issue? Looks like #14221 is closed.
@joshpollara it's on the back-burner right now, unfortunately, until I get cycles to come back to it. #14221 went stale since we were exploring alternative implementations like #14926
@esmet ok. thanks for the update!
I tried to do this with Wasm and succeeded. (I failed the first time, then finally got things exactly right).
See https://github.com/esnible/wasm-examples/tree/main/httpcall for an example of using EnvoyFilter to customize a response.
Any plans to implement this functionality any time soon ? I'm looking for something similar too.
Will it be possible to implement something that will allow to control the envoy response from the upstream server ? I'm think at using some custom envoy specific headers maybe, generated by the upstream server, which will be consumed by envoy and based on which the output will be formatted. I particular find this option appealing in the context of using envoy to do http to grpc transcoding, as out of the box, grpc doesn't offer much choices for response statuses.
+1 vote for this issue.
I want to rewrite the 4xx/5xx returned by the upstrem/backend service. I see that envoy 1.15.0 has been able to rewrite the error of envoy itself through local_reply_config, but it seems that it cannot rewrite the error returned by upstrem/backend. The function of local_reply_config is very good and can replace haproxy as the front end lb. It would be even better if could rewrite upstrem/backend.
I don’t know if my configuration is wrong, my configuration: