cglatot / pasta

Audio & Subtitle Track Changer for Plex
https://www.pastatool.com
270 stars 7 forks source link

Reverse proxy support? #41

Closed ponchohoncho closed 2 years ago

ponchohoncho commented 3 years ago

Hi! I'm trying to use Pasta behind an nginx reverse proxy (linuxserver/swag) and I can't seem to get it work right. I get a 501 BaD Gateway error. Looking at the SWAG logs, something in your container is refusing the connection, likely due to a hostname/fqdn thing?

2021/09/30 08:45:28 [error] 688#688: *1566 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.1, server: pasta.*, request: "GET / HTTP/2.0", upstream: "http://172.18.0.32:4481/", host: "pasta.customdomain.com"

Navigating to the IP:port works fine, but with a simple swag subdomain conf, it fails.

Thanks for your help!

alpaca1thunder commented 3 years ago

I swear I've gotten it to work with Swag a few months ago. I have the config saved, let me know if this works:

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

    server_name pasta.*;

    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 /ldaplogin;

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

        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;
        set $upstream_app pasta;
        set $upstream_port 80;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;
    }
}
alpaca1thunder commented 3 years ago

Also, in case anyone needs it--here is a Swag subfolder conf that worked for me

location /pasta {
    return 301 $scheme://$host/pasta/;
}

location ^~ /pasta/ {
    include /config/nginx/proxy.conf;
    resolver 127.0.0.11 valid=30s;
    set $upstream_app pasta;
    set $upstream_port 80;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    rewrite /pasta(.*) $1 break;
}
ponchohoncho commented 3 years ago

aha! It was I, the ding-dong, who put the public-facing port in the swag config. Thank you!

While we're here, I have the smallest docker-compose definition for future googlers

  pasta:
    image: cglatot/pasta
    container_name: pasta
    ports:
      - 4480:80 #i chose 4480, you can make choose own
    restart: unless-stopped
cglatot commented 2 years ago

Glad you were able to get this sorted. Thanks for the additional information for the future :D