• websockets and nginx

    From deon@21:2/116.1 to All on Mon Jan 7 18:09:15 2019
    Howdy,

    Has anybody setup nginx with websockets?

    I'm wanting to do two things - setup fTelnet on my website so that I can connect to my internal BBSes (which are not directly telnetable from the internet), and

    try out a viewdata viewer that I've managed to find, to connect enable a web videotex emulator

    It seems that this isnt enough...

    upstream videotex {
    server 10.1.3.77:516;
    }

    server {
    listen 80;
    ...
    location /wsapp/ {
    proxy_pass http://videotex;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_buffering off;
    }
    }

    ...deon

    _--_|\ | Deon George
    / \ | Chinwag BBS - A BBS on a PI in Docker!
    \_.__.*/ |
    V | Coming from the 'burbs of Melbourne, Australia

    --- Mystic BBS v1.12 A39 2018/04/21 (Raspberry Pi/32)
    * Origin: Chinwag | MysticBBS in Docker on a Pi! (21:2/116.1)
  • From StackFault@21:1/172 to deon on Tue Jan 8 21:15:12 2019
    Has anybody setup nginx with websockets?

    I'm wanting to do two things - setup fTelnet on my website so that I can connect to my internal BBSes (which are not directly telnetable from the internet), and

    I have a similar setup already but NGINX can't help you with that (or I haven't found the proper way, but I tried NGINX and HAProxy).

    I had success using websockify with fTelnet and it works very well. It's
    based on python.

    Should not be very hard to get it working as I don't remember having to
    battle with it very long but let me know if you run into issues and I will provide more details.

    Cheers!

    |15 ▀ ▐ |15StackFault |08<|03.|11.|15P|11h|03EN|11o|15M|11.|03.|08>
    |11 ▌ ▀ |11The Bottomless Abyss BBS
    |03 ▀ ▌▀ |03ssh|08.|072222 |08/ |03telnet|08.|072023 |08/ |03https
    |08 ▄■▐ |08bbs|07.|08bottomlessabyss|07.|08net

    --- Mystic BBS v1.12 A39 2018/04/21 (Linux/64)
    * Origin: The Bottomless Abyss BBS ■ bbs.bottomlessabyss.net (21:1/172)
  • From NuSkooler@21:1/121 to deon on Tue Jan 8 23:45:09 2019

    deon around Monday, January 7th...
    Has anybody setup nginx with websockets?

    I use Caddy instead of nginx, but it shouldn't matter much. Have you checked to
    see that the connection is making it through the proxy/terminator (nginx)? One
    thing with WebSockets is the handshake requires matching 'hixie` between client and server. If it's failing with that, you may be able to tweak either side.



    --- ENiGMA 1/2 v0.0.9-alpha (linux; x64; 10.13.0)
    * Origin: Xibalba -+- xibalba.l33t.codes:44510 (21:1/121)
  • From deon@21:2/116.1 to StackFault on Wed Jan 9 03:38:08 2019
    On 01/08/19, StackFault said the following...
    I have a similar setup already but NGINX can't help you with that (or I haven't found the proper way, but I tried NGINX and HAProxy).

    I had success using websockify with fTelnet and it works very well. It's based on python.

    I stumbled upon websockify, and found that somebody has created a nginx
    module for it. And its available in the docker hub, so it was as quick as "docker run" with a custom config file.

    It also looks like it supports dynamic configuration via lua - but the docker image doesnt have the lua module in it, so I'm going to re-create it with it, then I should be able to do something like ws://host/telnet?ip=x.x.x.x&port=X&secret=Y (I think anyway). (The secret is
    a dynamic password so that nobody can arbitrarily connect to any of my
    internal hosts.)

    I havent tested it out with fTelnet yet, but I have tested it out with my videotex implementation, and it works a treat. I now have a videotex emulator via a browser (instead of having to use a BBS micro emulator).

    I'll happily share the config and new docker image if you or anybody is interested.

    ...deon

    _--_|\ | Deon George
    / \ | Chinwag BBS - A BBS on a PI in Docker!
    \_.__.*/ |
    V | Coming from the 'burbs of Melbourne, Australia

    --- Mystic BBS v1.12 A39 2018/04/21 (Raspberry Pi/32)
    * Origin: Chinwag | MysticBBS in Docker on a Pi! (21:2/116.1)
  • From StackFault@21:1/172 to deon on Wed Jan 9 02:40:33 2019
    I stumbled upon websockify, and found that somebody has created a nginx module for it. And its available in the docker hub, so it was as quick as "docker run" with a custom config file.

    It also looks like it supports dynamic configuration via lua - but the docker image doesnt have the lua module in it, so I'm going to re-create it with it, then I should be able to do something like ws://host/telnet?ip=x.x.x.x&port=X&secret=Y (I think anyway). (The
    secret is a dynamic password so that nobody can arbitrarily connect to
    any of my internal hosts.)

    This is very good, I haven't revisited that in quite some time, I will give
    it a shot. Thanks for the insight.

    Cheers!

    |15 ▀ ▐ |15StackFault |08<|03.|11.|15P|11h|03EN|11o|15M|11.|03.|08>
    |11 ▌ ▀ |11The Bottomless Abyss BBS
    |03 ▀ ▌▀ |03ssh|08.|072222 |08/ |03telnet|08.|072023 |08/ |03https
    |08 ▄■▐ |08bbs|07.|08bottomlessabyss|07.|08net

    --- Mystic BBS v1.12 A39 2018/04/21 (Linux/64)
    * Origin: The Bottomless Abyss BBS ■ bbs.bottomlessabyss.net (21:1/172)
  • From echicken to deon on Wed Jan 9 03:16:31 2019
    Re: websockets and nginx
    By: deon to All on Mon Jan 07 2019 13:09:15

    Has anybody setup nginx with websockets?

    I have (as a reverse proxy to a websocket server anyway).

    proxy_pass http://videotex;

    Does videotex actually resolve to something? What port is that websocket server listening on? Might you need http://videotex:port?

    In the location stanza, in addition to the settings you've specified, I also have these:

    proxy_read_timeout 90;
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;

    Not sure if those would make much difference, but the first three are more likely to than the latter three.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-425-5435
  • From deon@21:2/116.1 to NuSkooler on Wed Jan 9 14:06:49 2019
    On 01/08/19, NuSkooler said the following...
    I use Caddy instead of nginx, but it shouldn't matter much. Have you checked to see that the connection is making it through the proxy/terminator (nginx)? One thing with WebSockets is the handshake requires matching 'hixie` between client and server. If it's failing
    with that, you may be able to tweak either side.

    My primary problem was that I read nginx websocket proxy, but thought "websocket server" :( When I realised that I needed a server to bridge the
    http and telnet I was good.

    Thanks for the tip on caddy, I might take a look - although as I posted previously, I found websockify as an nginx module which does work well...

    ...deon

    _--_|\ | Deon George
    / \ | Chinwag BBS - A BBS on a PI in Docker!
    \_.__.*/ |
    V | Coming from the 'burbs of Melbourne, Australia

    --- Mystic BBS v1.12 A39 2018/04/21 (Raspberry Pi/32)
    * Origin: Chinwag | MysticBBS in Docker on a Pi! (21:2/116.1)
  • From deon@21:2/116.1 to echicken on Wed Jan 9 14:09:38 2019
    On 01/08/19, echicken said the following...
    I have (as a reverse proxy to a websocket server anyway).

    Yeah, that was my problem. I thought it was a websocket server, but its a proxy.

    Found a module and it works a treat. So my "frontend" nginx proxies to a "backend" nginx with the websocket module and it works well...

    Now I want to compile it all again for armv7l so that the backend can run on the Pi.

    Thanks...

    ...deon

    _--_|\ | Deon George
    / \ | Chinwag BBS - A BBS on a PI in Docker!
    \_.__.*/ |
    V | Coming from the 'burbs of Melbourne, Australia

    --- Mystic BBS v1.12 A39 2018/04/21 (Raspberry Pi/32)
    * Origin: Chinwag | MysticBBS in Docker on a Pi! (21:2/116.1)