ruTorrent icon indicating copy to clipboard operation
ruTorrent copied to clipboard

Error when access rutorrent through reverse proxy nginx with subdomain

Open julienGrd opened this issue 1 year ago • 4 comments

Please complete the following tasks.

  • [X] Web browser cache cleared
  • [X] Link provided to install script if applicable
  • [X] Not using broken rtinst install script
  • [X] Web browser, ruTorrent, PHP and OS version provided

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

  • when i access to https://rutorrent.domain.fr, i dont land on rutorrent but on the defaut page of apache, i dont't know why the location int the proxy_pass is not respected, but its not so important
  • when i access to https://rutorrent.domain.fr/rutorrent, the website load. But not properly, its not useable. I have these error in the journal
[03.07.2024 19:13:08] WebUI started.
[03.07.2024 19:13:08] JS error: [https://rutorrent.jgdev.fr/rutorrent/ : 1] Uncaught SyntaxError: Unexpected token '<'
[03.07.2024 19:13:08] Bad response from server: (200 [parsererror,getuisettings]) <?php require_once( 'WebUISettings.php' ); $settings = WebUISettings::load(); $json = $settings->get(); CachedEcho::send($json,"application/json",false);
  • i don't know how, but this adress http://x.x.x.x/rutorrent still reachable, even if the website not load properly like the one with the subdomain
  • finally, the adress http://x.x.x.x:8081/rutorrent still loading correctly and is useable (so not through nginx)

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

julienGrd avatar Jul 03 '24 17:07 julienGrd

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.

stickz avatar Jul 03 '24 17:07 stickz

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

julienGrd avatar Jul 03 '24 18:07 julienGrd

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

stickz avatar Jul 03 '24 18:07 stickz

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 ?

julienGrd avatar Jul 05 '24 05:07 julienGrd

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

jevenski avatar Jul 13 '24 15:07 jevenski

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.

ac1dburnz avatar Jul 13 '24 16:07 ac1dburnz

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

julienGrd avatar Jul 14 '24 16:07 julienGrd