WebSocket NGINX SSL Termination Docker - vtortola/WebSocketListener GitHub Wiki

Overview

This echo server example uses NGINX to serve static files and WebSocket connections through the same port, providing SSL termination for both. It uses Docker and .Net Core 2.0.

This is a way of offloading the SSL configuration to the reverse proxy, removing that complexity from the WebSocket server.

Code can be located at: samples/NginxDocker

Details

The demo uses two Docker containers through Docker Compose:

  • websocket-app : .NET Core 2.0 app listening on port TCP 80 for incoming ws:// (non secure) WebSocket connections. There is no SSL provided at this point.
  • proxy : NGINX listening on port TCP 443 configured to serve static files (HTML, JS, CSS and images) through HTTPS, and bypass wss:// (secure) WebSocket connections to the path /socket towards websocket-app container.

Docker Compose will expose the port TCP 8721, as a way to access NGINX's TCP 443.

Run

There is a demo-up.sh script that will publish and launch the demo, and it can be accessed through https://localhost:8721