diff options
Diffstat (limited to 'memos/WM-027.txt')
| -rw-r--r-- | memos/WM-027.txt | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/memos/WM-027.txt b/memos/WM-027.txt new file mode 100644 index 0000000..ec50184 --- /dev/null +++ b/memos/WM-027.txt @@ -0,0 +1,69 @@ + + + + + + + +Document: WM-027 P. Webb +Category: Tutorial 2018.02.09 + + Using nginx and Socket.io + +Abstract + + Two of my favorite web technologies, together + +Body + + When pushing Socii[1] to production, I forgot how to account for the + fact that Socket.io[2] will not work out of the box with HTTPS + without a lil' extra configuration. + + On your nginx server, you'll want to edit your `default` file located + at `etc` > `nginx` > `sites-available`. I'll use one of my server + blocks as an example: + + ```nginx + server { + # removed for brevity + + location ~* \.io { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_set_header X-NginX-Proxy true; + proxy_pass http://localhost:1234; + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + proxy_redirect off; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_cache_key sfs$request_uri$scheme; + } + } + ``` + + The `proxy_pass` value will be the same as your app's. Actually, the + entire location directive is exactly the same, except for the opening + `location` bit. So, in the section that was removed for brevity you'd + have the same `location` block as above but `location ~* \.io` would + be replaced with `location /`. + + Once you're done editing, SSH into your server and run `nginx -t` to + ensure your configuration syntax is solid. Your changes won't be + applied until the nginx service (or your server) restarts and if you + configured something incorrectly, you don't want that to happen. If + you get a message saying the syntax is okay, run + `service nginx restart` and you're good to go! + + This is something I do once or twice a year and am stumped by so this + blog post is serving as an external memory unit. Hope this helps you + as well! 🕸 + +References + + [1] <https://hub.socii.network> + [2] <https://socket.io> |
