Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] How to use Jetty ProxyServlet for reverse proxying?

Hello,

I need to setup Jetty 9.4 as a HTTP reverse proxy, but the Jetty docs for ProxyServlet do not contain an example (or even any useful hints):

http://www.eclipse.org/jetty/documentation/jetty-9/index.html#proxy-servlet

I found an example by Joakim on Stack Overflow, but it isn't working.

https://stackoverflow.com/questions/52557018/jetty-9-x-proxyservlet-how-to-set-up-servletcontext-correctly-in-xml/52597488#52597488

I've tested with both Java 8 and Java 11 on Debian and Windows.

Using Jetty 9.4.43 rather than the 9.4.14 the example used, but I wouldn't expect that to be a problem?

$ mkdir proxy-test
$ cd proxy-test
$ java -jar ../jetty-distribution-9.4.43.v20210629/start.jar --add-to-start=http,deploy,proxy
$ java -jar ../jetty-distribution-9.4.43.v20210629/start.jar

Before creating the webapp, accessing localhost:8080 would usually give an unknown context error, but instead it gives the following:

HTTP ERROR 502 Bad Gateway
URI:	/
STATUS:	502
MESSAGE:	Bad Gateway
SERVLET:	org.eclipse.jetty.proxy.ProxyServlet-7e0b0338

Creating the webapp from Joakim's template (but with suitable valid proxyTo address) does not change anything - the requests gives the same error.

Indeed, it gives the same error for ANY webapp contexts, even the simplest directory with a file in it (until I remove --module=proxy from start.ini)

Is this a bug, did something change between 9.4.14 and 9.4.43, or am I missing something?


Thanks,

Peter


Back to the top