Novik / ruTorrent

Yet another web front-end for rTorrent
Other
2.02k stars 407 forks source link

Error when access rutorrent through reverse proxy nginx with subdomain #2686

Closed julienGrd closed 2 months ago

julienGrd commented 3 months ago

Please complete the following tasks.

Tell us about your environment

google chrome 126 rutorrent : 4.3.5 PHP : 8.3 OS ubuntu 24

Tell us how you installed ruTorrent

https://bitsparadise.info/index.php/2020/04/26/creer-votre-seedbox-avec-rtorrent-rutorrent-sur-votre-machine-ubuntu/ for the installation of rtorrent + rutorrent https://medium.com/@m.fareed607/how-to-set-up-an-nginx-reverse-proxy-server-and-enable-https-with-certbot-bbab9feb6338 for the setup of nginx as reverse proxy + SLL

Describe the bug

Hello i follow a tutorial for the installation of rutorrent (https://bitsparadise.info/index.php/2020/04/26/creer-votre-seedbox-avec-rtorrent-rutorrent-sur-votre-machine-ubuntu/) an a fresh ubuntu 24.

at this step, rutorrent was working well at this adresse http://x.x.x.x/rutorrent (i had to install a patch for rtorrent, because of ubuntu 24, but i think its not related about my problems). i test from end to end including rtorrent and it was working good

Next i follow this tutorial (https://medium.com/@m.fareed607/how-to-set-up-an-nginx-reverse-proxy-server-and-enable-https-with-certbot-bbab9feb6338) for set a subdomain on this app, https://rutorrent.mydomain.fr

for that, i had to put the defaut apache port to 8081

also, this is my conf nginx

server {
    listen 443 ssl;
    server_name rutorrent.domain.fr;
    ssl_certificate /etc/letsencrypt/live/rutorrent.domain.fr/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/rutorrent.domain.fr/privkey.pem;
    location / {
        proxy_pass http://127.0.0.1:8081/rutorrent;
        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 X-Forwarded-Proto $scheme;
    }
}`

I have many problems after this configuration that i don't understand

Do you know whats wrong or which mismatch i made to have these kinfs of errors ?

thanks !

Steps to reproduce

No response

Expected behavior

No response

Additional context

No response

stickz commented 3 months ago

Hello @julienGrd, I notice that you have a parse error for parsererror,getuisettings. I would recommend deleting WebUISettings.dat in your rutorrent/share folder. Afterwards, please ensure this directory has proper read and write permissions. ruTorrent v4.3.5 will need to read this file and write to it.

julienGrd commented 3 months ago

i just delete this file, made a chmod 777 on the folder share, and restart apache and nginx, and it seem nothing change

stickz commented 3 months ago

Le guide français contient d'anciennes instructions. Utilisez "git clone" pour obtenir la dernière version de ruTorrent.

cd /var/www/html
git clone https://github.com/Novik/ruTorrent

Modifiez ensuite un paramètre pour augmenter la vitesse. $localHostedMode = true; https://github.com/Novik/ruTorrent/blob/9bf6e15c4864a71ff9e9ca5ea689fd001931279b/conf/config.php#L62

Finalement cette version de rTorrent a 5 ans. Il y a des problèmes avec le logiciel. Vous pouvez essayer ma version de rTorrent. Cent mille personnes l'utilisent sur Docker. https://github.com/stickz/rutorrent-rtorrent-build-scripts

julienGrd commented 3 months ago

Thanks for your script but i don't see actually how it can resolve my problems.

Actually the part rtorrent + rutorrent seem working fine if i acces it through apache, its only when i start expose the website through a reverse proxy it not work well. I don't know maybe i miss something in the nginx configuration ?

jevenski commented 2 months ago

As per your conf, Nginx is capturing all requests matching with / and proxy passing them to http://127.0.0.1:8081/rutorrent, so http://rutorrent.domain/index.html is proxy passed to Apache as http://127.0.0.1:8081/rutorrentindex.html, which will return a 404 and end up at Apache's default page.

I bet adding a trailing slash to the proxy_pass destination will sort things out.

Reference (see the "To slash or not to slash" part): Nginx Proxy Pass

ac1dburnz commented 2 months ago

If you want a much easier process, I would suggest using Nginx Proxy Manager. It will speed up the process and make it more streamlined with fewer chances of errors.

julienGrd commented 2 months ago

thanks for your answer guys.

I was finally able to sole my problems. It was a mistake from myself. i was actually confuse with the nginx system of sitesEnabled and sitesAvalaible. So the configuration put previously was actually not the one which was interpreted.

I correct the configuration in proper file and now everything work as expected

this is a actual working configuration for whose interested (i still have to put the /rutorrent to access to the app but its not so much a problem for me)

  root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;
        server_name subdomain.domain.fr; # managed by Certbot
    location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
        proxy_pass http://127.0.0.1:8081/;
        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 X-Forwarded-Proto $scheme;
 auth_basic "Restricted";
        auth_basic_user_file /etc/nginx/htpasswd;
                try_files $uri $uri/ =404;
        }

        # pass PHP scripts to FastCGI server
        #
        #location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
        #       fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #       deny all;
        #}

    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/subdomain.domain.fr/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/subdomain.domain.fr/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot