Play 2 framework does not support Secure WebSocket. So I use nginx as a proxy to work as a SSL endpoint for WSS connection (as suggested in the post How to use TLS in Play!Framework WebSockets ("wss://")). Everything works with nginx. Do you know if this is possible also with Apache HTTP Server? How should I change the httpd.conf to have Apache as a SSL endpoint for WSS?
Asked
Active
Viewed 427 times
1 Answers
0
What makes you think Play doesn't support secure websocket? It does, secure websockets is just the regular websocket protocol over https instead of HTTP. Just enable https, and there you have it, secure websocket support.
You can proxy websockets in Apache using this:
https://httpd.apache.org/docs/2.4/mod/mod_proxy_wstunnel.html
But you'd be crazy to do so, Apache uses a thread per connection, and websockets uses persistent connections, using a whole thread per connection when you're expecting a lot of them is a waste of resources, a non blocking proxy like nginx makes a lot more sense.

James Roper
- 12,695
- 46
- 45
-
Thanks. I didn't know that nginx is non-blocking. Now I understand why Apache is not used in this case. However, I've tried to enable https in Play by setting "https.port=9433" in application.conf but it doesn't work. I didn't set the other parameters (play.server.https.keyStore.path, type, password and algorithm) because I've read that they have default values. – Mattia Micomonaco Nov 19 '15 at 12:58
-
What's the error in your browsers developer console? Note that without any additional configuration, Play generates a self signed certificate which your browser will reject by default, you'll need to configure your browser to trust that certificate. – James Roper Nov 19 '15 at 20:39
-
The WebSocket client is written in C with libwebsocket. But I think it is the same as the browser. I should configure it to trust the certificate. – Mattia Micomonaco Nov 20 '15 at 09:01