You are not logged in.

#1 2020-05-13 17:37:24

rubenvb
Member
Registered: 2011-01-14
Posts: 104

Transmission web interface through nginx reverse proxy gives 502

I have a simple nginx to Transmission reverse proxy setup.
It works, rock solid, but only after I do a "systemctl restart transmission" after each boot.
Luckily, this box runs nearly 24/7 and is only rebooted if I'm messing with it or installing upgrades.

From a fresh boot, surfing to the transmission web interface (be it from local network or outside) I am greeted with nginx' "502 Bad Gateway" page.
After restarting transmission, it works fine.

The nginx log shows this after trying to load the page three times:

nginx[494]: 2020/05/13 19:15:10 [error] 494#494: *33 connect() failed (111: Connection refused) while connecting to upstream, client: <my DHCP server address>, server: <my domain>, request: "GET /transmission/web/ HTTP/1.1", upstream: "http://127.0.0.1:9091/transmission/web/", host: "<my domain>"
nginx[494]: 2020/05/13 19:20:24 [crit] 494#494: *36 connect() to unix:/run/php-fpm/php-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: <my DHCP server address>, server: <my domain>, request: "GET /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/php-fpm.sock:", host: "my domain"
nginx[494]: 2020/05/13 19:22:54 [error] 494#494: *38 connect() failed (111: Connection refused) while connecting to upstream, client: <my DHCP server address>, server: <my domain>, request: "GET /transmission/web/ HTTP/1.1", upstream: "http://127.0.0.1:9091/transmission/web/", host: "<my domain>"

Here, <my domain> is something like www.example.com, the domain I use to access my box from outside my LAN, and <my DHCP server address> is my router's IP (the "gateway" field)

Nginx configuration is this:

worker_processes 1;
error_log /var/log/nginx/error.log;
error_log /var/log/nginx/error.log  notice;
error_log /var/log/nginx/error.log  info;
events {
    worker_connections 1024;
}
http {
    include mime.types;
    default_type application/octet-stream;
    sendfile on;
    keepalive_timeout 65;

    server {
        listen 80 default;
        server_name <my domain> <my internal IP>;
        return 307 https://$server_name$request_uri;
    }

    upstream php {
        server unix:/run/php-fpm/php-fpm.sock;
    }

    server {
        listen 443 ssl;
        server_name <my domain> <my internal IP>;
        ssl_certificate /etc/letsencrypt/live/<my domain>/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/<my domain>/privkey.pem; # managed by Certbot
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout 5m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;
        ssl_protocols TLSv1.3 SSLv3;

        #auth_basic "closed website";
        #auth_basic_user_file /etc/nginx/authentication;
        
        root /srv/http/;

        location ^~ /transmission {
            proxy_pass http://127.0.0.1:9091;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Connection "";
            index index.html index.htm;

            auth_basic "closed website";
            auth_basic_user_file /etc/nginx/authentication;
        }

        location ~ \.php$ {
            include fastcgi.conf;
            fastcgi_intercept_errors on;
            fastcgi_pass php;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
        }  
    }
}

It was set up a long while ago, so it may contain some old, now sub-optimal, bits. I know the PHP bits aren't relevant for Transmission, but that's what my config looks like.

Does anyone have any idea what is going wrong, and more importantly, how to fix this?

Thanks!

Offline

Board footer

Powered by FluxBB