jetty.project
jetty.project copied to clipboard
Proxy module is not usable out of the box - loop causes 502 error
Jetty version(s) 9.4.x (including 9.4.43)
Java version/vendor `OpenJDK 11, OpenJDK 8, Oracle 8
OS type/version Debian GNU/Linux 10
Description Trying to use Jetty as reverse proxy via ProxyServlet results in 502 error (even for unrelated webapps).
Per Simone:
I checked and the module as it is is not usable out of the box. What happens is that because there is no URL rewriting, the ProxyServlet will proxy to itself in a loop until the proxied headers become too large and an error is reported, which results in the 502.
How to reproduce? Enable the proxy module using --add-to-start Example script at https://www.eclipse.org/lists/jetty-users/msg09980.html
My use case is attempting to serve static files whilst proxying all other requests (for a single context) to another server.
The aim is to use TryFilesFilter to serve static files with Default servlet then have all other URLs proxied to a non-Jetty backend server over HTTP. (It doesn't currently support FastCGI or I'd use that.)
So yeah, no need for balancing, content transforming, etc - just need the other server to handle the requests which would otherwise 404.
I've been experimenting with using BalancerServlet with a single member as a workaround, and found a minor bug.
If there are no members defined it gives a divide by zero error. (I expected something along the lines of "no balancer members defined"). Adding a member via setInitParameter balancerMember.a.proxyTo and it then starts proxying.
However, there is also a more significant issue: Given a servletMapping of /proxy/* a request to http://localhost:8080/proxy/ is sent to http://localhost:8081/proxy/ I expected it would go instead to http://localhost:8081/ - i.e. that the servletMapping would be removed.
If the inclusion of servletMapping is deliberate (or can't be fixed without breaking backwards compatibility), then an additional parameter to explicitly exclude it would be useful. (For both BalancerServlet proxyTo and if proxyTo is added to ProxyServlet.)
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.