{"action":"created","issue":{"url":"https://api.github.com/repos/housleyjk/ws-rs/issues/6","labels_url":"https://api.github.com/repos/housleyjk/ws-rs/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/housleyjk/ws-rs/issues/6/comments","events_url":"https://api.github.com/repos/housleyjk/ws-rs/issues/6/events","html_url":"https://github.com/housleyjk/ws-rs/issues/6","id":115935790,"number":6,"title":"How to proxy ssl using nginx","user":{"login":"housleyjk","id":5325564,"avatar_url":"https://avatars.githubusercontent.com/u/5325564?v=3","gravatar_id":"","url":"https://api.github.com/users/housleyjk","html_url":"https://github.com/housleyjk","followers_url":"https://api.github.com/users/housleyjk/followers","following_url":"https://api.github.com/users/housleyjk/following{/other_user}","gists_url":"https://api.github.com/users/housleyjk/gists{/gist_id}","starred_url":"https://api.github.com/users/housleyjk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/housleyjk/subscriptions","organizations_url":"https://api.github.com/users/housleyjk/orgs","repos_url":"https://api.github.com/users/housleyjk/repos","events_url":"https://api.github.com/users/housleyjk/events{/privacy}","received_events_url":"https://api.github.com/users/housleyjk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/housleyjk/ws-rs/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-09T18:25:29Z","updated_at":"2015-11-10T01:51:06Z","closed_at":null,"body":"In a production environment, it is a good idea to run the WebSocket server(s) behind a reverse proxy such as nginx. This allows for supporting more complex configurations than would otherwise be possible with a bare WebSocket server. One major advantage of using a reverse proxy is support for `wss` (SSL). Recent versions of nginx support WebSockets, so an example config is actually rather simple:\r\n\r\n```nginx\r\nserver {\r\n    listen localhost:3443;\r\n        \r\n    ssl on;\r\n    ssl_certificate /etc/nginx/ssl/snakeoil.crt;\r\n    ssl_certificate_key /etc/nginx/ssl/snakeoil.key;\r\n\r\n    location / {                                                                                                                                                                                         \r\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\n        proxy_pass http://127.0.0.1:3012;                                                                                                                                                                                                  \r\n    }     \r\n}\r\n```\r\n\r\nThis example demonstrates running the server on a local machine with a self-signed key. In order to work, the WebSocket server needs to run on port 3012, and clients connect through port 3443. For example, in javascript `var socket = new WebSocket(\"wss://localhost:3443\")`. The `location /` directive means that only websocket connections will be available on this server. \r\n\r\nThis local configuration was tested using nginx 1.8."},"comment":{"url":"https://api.github.com/repos/housleyjk/ws-rs/issues/comments/155257551","html_url":"https://github.com/housleyjk/ws-rs/issues/6#issuecomment-155257551","issue_url":"https://api.github.com/repos/housleyjk/ws-rs/issues/6","id":155257551,"user":{"login":"boogerlad","id":1903750,"avatar_url":"https://avatars.githubusercontent.com/u/1903750?v=3","gravatar_id":"","url":"https://api.github.com/users/boogerlad","html_url":"https://github.com/boogerlad","followers_url":"https://api.github.com/users/boogerlad/followers","following_url":"https://api.github.com/users/boogerlad/following{/other_user}","gists_url":"https://api.github.com/users/boogerlad/gists{/gist_id}","starred_url":"https://api.github.com/users/boogerlad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boogerlad/subscriptions","organizations_url":"https://api.github.com/users/boogerlad/orgs","repos_url":"https://api.github.com/users/boogerlad/repos","events_url":"https://api.github.com/users/boogerlad/events{/privacy}","received_events_url":"https://api.github.com/users/boogerlad/received_events","type":"User","site_admin":false},"created_at":"2015-11-10T01:51:06Z","updated_at":"2015-11-10T01:51:06Z","body":"Sorry to bother you again, but if the location / directive means that only websocket connections will be available on this server, how would I serve static assets from the same port? For my clients, they only have port 80 and port 443 open. (or static assets from port 80 and websocket from port 443???) "}}