-1

Reverse proxying https://example.net to http://localhost:8080 works fine with Caddy reverse_proxy.

Reverse proxying ws://example.net to ws://localhost:8080 works also fine with Caddy reverse proxy.

But I do not know how to reverse proxy wss://example.net to ws://localhost:8080 with Caddy reversy proxy for enabling web sockets.

--

I have tried out the https://spring.io/guides/gs/messaging-stomp-websocket tutorial. It tells, how to use websockets with Spring Boot.

When I try it with localhost:8080, everything is fine.

When I run it on a webserver as localhost:8080, I have configured Caddy

example.net:80 {
    reverse_proxy localhost:8080
}

and I have configured app.js to the more generic brokerUrl '/gs-guide-websocket' (without the ws://localhost:8080).

it also works fine als http://example.net without TLS.

Now I tried to enable TLS and so I configured Caddy to

example.net {
    reverse_proxy localhost:8080
}

I want have it locally running via http://localhost:8080 using Caddy to bring this out to https://example.net .

With normal websites (without websockets), this works fine.

So when I try, the website https://example.net itself is loaded.

But the connection to Websocket fails:

WebSocket connection to 'wss://example.net/gs-guide-websocket' failed.

I want to achieve that wss://example.net/gs-guide-websocket is proxied to ws://localhost:8080/gs-guide-websocket.

How to make it working?

0

1 Answer 1

0

User ferrybig from caddy.community could help me:

https://caddy.community/t/reverse-proxy-to-websocket-does-not-work-via-https/33022/3

The solution is:

registry.addEndpoint("/gs-guide-websocket").setAllowedOrigins("https://example.net");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.