butlerx / wetty

Terminal in browser over http/https. (Ajaxterm/Anyterm alternative, but much better)
https://butlerx.github.io/wetty
MIT License
4.26k stars 670 forks source link

Reverse proxy through linuxserver/swag with subdomain rather than subfolder #373

Closed ken8521 closed 9 months ago

ken8521 commented 2 years ago

Not sure if this is a bug or a feature request (I suspect the later)...

I'm trying to reverse proxy wetty through linuxserver/swag. The container works fine locally at ip:3000/wetty. I add it to my swag network, I then create a wetty.subdomain.conf file (see below), restart swag, then restart wetty... but then I just get what looks like a windows explorer window that says "reconnecting" over and over till I close the tab. I suspect this is because I can't add the /wetty to the end of the $upstream port in the subdomain.conf file. I'm assuming this would work fine on subfolder, but my preference is to use subdomains.

Any suggestion would be greatly appreciated. Edit: I'm not sure why the below split into 3 sections, but it's all there. If you'd like to look at it w/o the weird formatting, here's a pastebin of the file. https://pastebin.com/AvVurN3i

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name wetty.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    # enable for ldap auth, fill in ldap details in ldap.conf
    #include /config/nginx/ldap.conf;

    # enable for Authelia
    #include /config/nginx/authelia-server.conf;

#
    location / {
        # enable the next two lines for http auth
        #auth_basic "Restricted";
        #auth_basic_user_file /config/nginx/.htpasswd;

        # enable the next two lines for ldap auth
        #auth_request /auth;
        #error_page 401 =200 /login;

        # enable for Authelia
        #include /config/nginx/authelia-location.conf;

        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_app 192.168.1.166;
        set $upstream_port 3000;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port/wetty;
        access_log off;
    }

}
shimile commented 2 years ago

Well I ain't no expert, but...

Have you considered running wetty with '--base /' and then using the proxy_pass without /wetty in it?

Because... wetty expects all its' requests to come with /wetty/ prefix, and builds its' paths according to it. But when you map / to /wetty in Nginx, essentially when user goes to / it is forwarded to /wetty so the app starts to load (as the right HTML is sent to the client), but then when the app asks for /wetty/whatever, your config, IMO, actually makes it go to /wetty/wetty/whatever from the wetty service perspective.

If you do want the /wetty/ in your URLs (though it doesn't make sense to me if you gave it a unique hostname instead...), I think the proper way to reverse-proxy this in Nginx would be to use 'location /wetty' to redirect to the proxy_pass you've chosen, and then have another 'location = /' that would have a single redirect directive to redirect people who hit the / URL into /wetty/

Hope this helps...

butlerx commented 2 years ago

@shimile assessment sounds correct please report back if it helps

ken8521 commented 1 year ago

I moved on to another solution, but just happened to see this and never saw the answer that was posted until a few minutes ago. I didn't notice the -b switch I could use when I tried this the first time.

docker run --restart=always --name=wetty -p 3000:3000 wettyoss/wetty --ssh-host=192.168.1.166 -b

Seems to have done the trick and I can reverse proxy through swag w/ the subdomain.conf I posted above.

Thanks!

ken8521 commented 1 year ago

Thanks

github-actions[bot] commented 9 months ago

Stale issue message