themepark-dev / theme.park

A collection of themes/skins for 50 selfhosted apps!
https://theme-park.dev
MIT License
2.41k stars 788 forks source link

[Bug] qBit theme no longer compatible with version 4.3.1 #131

Closed rg9400 closed 3 years ago

rg9400 commented 3 years ago

Inexplicably, the subfilter method to inject the qBit theme is now breaking the reverse proxy. If I comment it out, the proxy works perfectly fine. This is a new issue as the below errors never occurred previously, and I was able to access the relevant tabs + functionality. It seems an update created this incompatibility

qbit nginx RP

location ^~ /qbittorrent/ {
    auth_request /auth-0;
    include /config/nginx/proxy.conf;
    set $theme_app qbittorrent;
    set $upstream_app qbittorrent;
    set $upstream_port 8070;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;
    proxy_hide_header   "content-security-policy";
    http2_push_preload  on;
    proxy_set_header Host $upstream_app:$upstream_port;
    include /config/nginx/themes/themepark.conf;
    rewrite /qbittorrent(.*) $1 break;
}

themepark.conf with $tptheme set to organizr-dark

    proxy_set_header Accept-Encoding "";
    sub_filter
    '</head>'
    '<link rel="stylesheet" type="text/css" href="https://gilbn.github.io/theme.park/CSS/themes/$theme_app/$tptheme.css">
    </head>';
    sub_filter_once on;

I comment out the line include /config/nginx/themes/themepark.conf; to get it working again.

There are a bunch of errors. Some that impact functionality are the inability to navigate to the RSS tab. All of these disappear when removing the above line.

VM84:281 Uncaught SyntaxError: Invalid or unexpected token
    at Object.o.exec (mootools-1.2-core-yc.js:111)
    at Object.success (mootools-1.2-core-yc.js:494)
    at Object.i.extend.$owner (mootools-1.2-core-yc.js:141)
    at Object.onStateChange (mootools-1.2-core-yc.js:470)
    at Object.i.extend.$owner (mootools-1.2-core-yc.js:141)
    at XMLHttpRequest.<anonymous> (mootools-1.2-core-yc.js:88)
client.js?locale=en&v=6chkjy:956 Uncaught TypeError: Cannot read property 'init' of undefined
    at HTMLLIElement.showRssTab (client.js?locale=en&v=6chkjy:956)
    at HTMLLIElement.e (mootools-1.2-core-yc.js:368)
client.js?locale=en&v=6chkjy:971 Uncaught TypeError: Cannot read property 'unload' of undefined
    at hideRssTab (client.js?locale=en&v=6chkjy:971)
    at HTMLLIElement.showTransfersTab (client.js?locale=en&v=6chkjy:927)
    at HTMLLIElement.e (mootools-1.2-core-yc.js:368)
GilbN commented 3 years ago

I'm unable to replicate this. Tested on lsio qbittorrent latest.

location /qbt/ {
    proxy_pass              http://192.168.1.34:8080/;
    proxy_set_header        X-Forwarded-Host        $server_name:$server_port;
    proxy_hide_header       Referer;
    proxy_hide_header       Origin;
    proxy_set_header        Referer                 '';
    proxy_set_header        Origin                  '';
    add_header              X-Frame-Options         "SAMEORIGIN";

    set $app qbittorrent;
    include /config/nginx/theme-park.conf;

    proxy_hide_header   "x-webkit-csp";
    proxy_hide_header   "content-security-policy";
  }

And their proxy conf sample.

## Version 2020/12/09
# qbittorrent does not require a base url setting

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

location ^~ /qbittorrent/ {

set $app qbittorrent;
include /config/nginx/theme-park.conf;

proxy_hide_header   "x-webkit-csp";
proxy_hide_header   "content-security-policy";

    include /config/nginx/proxy.conf;
    #resolver 127.0.0.11 valid=30s;
    set $upstream_app 192.168.1.34;
    set $upstream_port 8080;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    rewrite /qbittorrent(.*) $1 break;

    proxy_set_header Referer '';
    proxy_set_header Host $upstream_app:$upstream_port;
}

location ^~ /qbittorrent/api {
    include /config/nginx/proxy.conf;
    #resolver 127.0.0.11 valid=30s;
    set $upstream_app 192.168.1.34;
    set $upstream_port 8080;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    rewrite /qbittorrent(.*) $1 break;

    proxy_set_header Referer '';
    proxy_set_header Host $upstream_app:$upstream_port;
}

location ^~ /qbittorrent/command {
    include /config/nginx/proxy.conf;
    #resolver 127.0.0.11 valid=30s;
    set $upstream_app 192.168.1.34;
    set $upstream_port 8080;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    rewrite /qbittorrent(.*) $1 break;

    proxy_set_header Referer '';
    proxy_set_header Host $upstream_app:$upstream_port;
}

location ^~ /qbittorrent/query {
    include /config/nginx/proxy.conf;
    #resolver 127.0.0.11 valid=30s;
    set $upstream_app 192.168.1.34;
    set $upstream_port 8080;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    rewrite /qbittorrent(.*) $1 break;

    proxy_set_header Referer '';
    proxy_set_header Host $upstream_app:$upstream_port;
}

location ^~ /qbittorrent/login {
    include /config/nginx/proxy.conf;
    #resolver 127.0.0.11 valid=30s;
    set $upstream_app 192.168.1.34;
    set $upstream_port 8080;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    rewrite /qbittorrent(.*) $1 break;

    proxy_set_header Referer '';
    proxy_set_header Host $upstream_app:$upstream_port;
}

location ^~ /qbittorrent/sync {
    include /config/nginx/proxy.conf;
    #resolver 127.0.0.11 valid=30s;
    set $upstream_app 192.168.1.34;
    set $upstream_port 8080;
    set $upstream_proto http;
    proxy_pass $upstream_proto://$upstream_app:$upstream_port;

    rewrite /qbittorrent(.*) $1 break;

    proxy_set_header Referer '';
    proxy_set_header Host $upstream_app:$upstream_port;
}
rcdailey commented 3 years ago

@gilbN what browser are you using? Did you click the RSS tab (I don't see that in your screenshot)? Did the RSS tab switch to something for you?

GilbN commented 3 years ago

@rcdailey I'm using chrome.

Tested with FF

I've also tested using the Binhex QbittorrentVPN container, with and without VPN activated. Still works. Tested your @rg9400 nginx conf.

rcdailey commented 3 years ago

There's an issue somewhere, I don't know where it is. I think this is the right place to try to find out the problem. I also have the same problem, so between 2 people we need to find out what is broken.

GilbN commented 3 years ago

There's an issue somewhere, I don't know where it is. I think this is the right place to try to find out the problem. I also have the same problem, so between 2 people we need to find out what is broken.

Can you try a completely new qbit config?
I use deluge, so I'm testing on a fresh install with nothing setup.

rg9400 commented 3 years ago

This is resolved by the answer in https://github.com/gilbN/theme.park/issues/132, quoted below

using sub_filter to replace <noscript> tag instead of the </head> tag fixed the issue for me. basically move the tag to group with other css files before javascript script tags.