pxlsspace/Pxls

Apache proxy

GnaXi opened this issue · 2 comments

GnaXi commented

Hi!

I keep getting the following error in the console:

11:50:54.416 [XNIO-1 I/O-13] ERROR io.undertow.request - UT005071: Undertow request failed HttpServerExchange{ GET /ws}
java.lang.IllegalStateException: UT000133: Request did not contain an Upgrade header, upgrade is not permitted
at io.undertow.server.HttpServerExchange.upgradeChannel(HttpServerExchange.java:923) ~[pxls-1.0-SNAPSHOT.jar:?]
at io.undertow.websockets.WebSocketProtocolHandshakeHandler.handleRequest(WebSocketProtocolHandshakeHandler.java:193) ~[pxls-1.0-SNAPSHOT.jar:?]
at space.pxls.util.HttpPermissionGate.handleRequest(HttpPermissionGate.java:35) ~[pxls-1.0-SNAPSHOT.jar:?]
at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:104) ~[pxls-1.0-SNAPSHOT.jar:?]
at io.undertow.server.RoutingHandler.handleNoMatch(RoutingHandler.java:112) ~[pxls-1.0-SNAPSHOT.jar:?]
at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:77) ~[pxls-1.0-SNAPSHOT.jar:?]
at io.undertow.server.handlers.form.EagerFormParsingHandler.handleRequest(EagerFormParsingHandler.java:73) ~[pxls-1.0-SNAPSHOT.jar:?]
at space.pxls.util.AuthReader.handleRequest(AuthReader.java:55) ~[pxls-1.0-SNAPSHOT.jar:?]
at space.pxls.util.IPReader.handleRequest(IPReader.java:36) ~[pxls-1.0-SNAPSHOT.jar:?]
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393) ~[pxls-1.0-SNAPSHOT.jar:?]
at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:256) ~[pxls-1.0-SNAPSHOT.jar:?]
at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136) ~[pxls-1.0-SNAPSHOT.jar:?]
at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:59) ~[pxls-1.0-SNAPSHOT.jar:?]
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) ~[pxls-1.0-SNAPSHOT.jar:?]
at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66) ~[pxls-1.0-SNAPSHOT.jar:?]
at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89) ~[pxls-1.0-SNAPSHOT.jar:?]
at org.xnio.nio.WorkerThread.run(WorkerThread.java:591) ~[pxls-1.0-SNAPSHOT.jar:?]

I read that it is caused by using a proxy and there seems to be a working solution for nginx:

location /ws {
proxy_connect_timeout 7d;
proxy_send_timeout 7d;
proxy_read_timeout 7d;
proxy_pass http://localhost:4567/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}

However, I am running on Apache. Anyone got a working solution for running Pxls with an Apache proxy in front?

Interesting. I'm not too familiar with Apache but my best guess (and the usual issue with proxies) is that it's something with websockets.

My best recommendation is to use NGINX Proxy Manager. It's super simple to setup, it gives you an easy way of making SSL certs and automatically renews them, and it gives you easy control over the mess of proxies you'll end up accumulating. Make sure to enable "websockets support" when making the reverse proxy. On top of that, NGINX is faster and is designed with the assumption that you'll use SSL.

Using CasaOS to install NGINX Proxy Manager is about as easy as installing an app on your phone. I highly recommend it to start! Not to mention, it's a great homepage for your server and certainly helps with managing the chaos.

It's still crazy to me that the most popular web servers don't support somewhat modern web technologies. Either way, just try NGINX because that's been the most reliable setup for me. Good luck!

GnaXi commented

I completely forgot this issue, because I later resolved it myself. But you are indeed correct. It had to do with websockets.
For another's using Apache for proxying Pxls, this is what you have to add to your VirtualHost to fix the issue:

ProxyPass /ws ws://localhost/ws/ upgrade=websocket
ProxyPassReverse /ws ws://localhost/ws/ upgrade=websocket