Page 1 of 2

[2.0.0 Beta 1] login doesn't play nice with reverse proxy

Posted: March 11th, 2017, 6:44 am
by sleepblanket
Hi, since updating to V2, the login process doesn't play nice with my apache reverse proxy.

When logging in I keep getting forced to the /sabnzbd directory even though my proxy is at /sab

Here's what happens when I haven't authenticate.....
- Visit /sab
- Get forced to /sabnzbd/login
- 404 error
- Edit URI to /sab/login
- Login as normal
- Forced to /sabnzbd
- 404 error
- Edit URI to /sab
- Everything then works as normal

If I'm already authenticated, I can visit /sab and carry on as normal.

I've downgraded to 1.2.1 and I can login as normal, which makes me think it's a V2 issue and not anything my end.

Here's my apache2 conf

Code: Select all

        <Location /sab>
        ProxyPass http://127.0.0.1:33333/sabnzbd
        ProxyPassReverse http://127.0.0.1:33333/sabnzbd
        </Location>
System info Ubuntu Sever 16 LTS

Code: Select all

Version:	1.2.1 [d32cf57]
Uptime:	22m
Config File:	/home/.sabnzbd/sabnzbd.ini
Used cache:	Cached 0 articles (0 B)
Parameters:	/usr/bin/sabnzbdplus --daemon --pidfile /var/run/sabnzbdplus/pid --server 127.0.0.1:33333
Python Version:	2.7.12 (default, Nov 19 2016, 06:48:10) [GCC 5.4.0 20160609] [UTF-8]
OpenSSL:	OpenSSL 1.0.2g 1 Mar 2016   [TLS v1.2, TLS v1.1, TLS v1]
Thanks.

Re: [2.0.0 Beta 1] login doesn't play nice with reverse prox

Posted: March 11th, 2017, 6:55 am
by Robius
I had the same problem with Nginx. i followed the same steps as you and had to update the URL string to make it work. Eventually i got it to work with the below

When i go to the page now after playing around for a while i end up with a double // Trailing slash at the end of the URL but it all seems to work

location /s3 {
#X-Forwarded-For is used for forwarding IP addresses
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass hxxp://192.168.1.100:8080/sabnzbd;

Re: [2.0.0 Beta 1] login doesn't play nice with reverse prox

Posted: March 11th, 2017, 11:58 am
by safihre
What do you expect?
Of course it will direct from /sabnzbd/login and then back to /sabnzbd, what else?

Re: [2.0.0 Beta 1] login doesn't play nice with reverse prox

Posted: March 11th, 2017, 1:36 pm
by sleepblanket
I expect to be able to login without getting 404 errors. It worked perfectly in versions v0 and v1. If I install v2, I get 404 errors. I downgrade back to v1, the 404 errors go away.

I think the login page is trying to do hxxp://localhost:xxxxx/sabnzbd/sabnzbd/login

Re: [2.0.0 Beta 1] login doesn't play nice with reverse prox

Posted: March 11th, 2017, 2:06 pm
by safihre
Aha, well that would be wrong indeed.
What it is trying to send is a relative URL (or at least it should, I will verify that), namely /sabnzbd/

Also, sabnzbd doesn't have 404's, it will always just redirect to the main page. So maybe it is a proxy setting?

We went from sending http redirects with full paths including the full domain to relative redirects. So probably the rewriting of the URLs is going wrong?
This was actually done to help proxy users, make it easier.

Re: [2.0.0 Beta 1] login doesn't play nice with reverse prox

Posted: May 28th, 2017, 9:12 am
by brdhse1
I'm seeing the same problem as sleepblanket with version 2.0.1 [be5bebb]. I have an apache reverse proxy and the behavior is exactly the same. This worked fine with version < 2.

safihre did you determine if this was a bug?

Re: [2.0.0 Beta 1] login doesn't play nice with reverse prox

Posted: May 28th, 2017, 12:07 pm
by safihre
Not a bug perse, but a change in behavior indeed. It expects to be either on / or /sabnzbd/
So changing it to one of those should work.

Re: [2.0.0 Beta 1] login doesn't play nice with reverse proxy

Posted: September 1st, 2017, 5:29 pm
by E71
Safihre, Issue #904 wrote:Can anyone tell me if this is actually needed?
Since we bind to both / and /sabnzbd isn't that enough?
I'm afraid without it I'm stuck at v1.2.3 since I do not wish to use easily guessable URIs on my public facing web server.

Re: [2.0.0 Beta 1] login doesn't play nice with reverse proxy

Posted: September 1st, 2017, 5:44 pm
by safihre
So that's what needs to be implemented? Being able to change /sabnzbd/ to anything? No experience myself with these things but I can try to implement it :)

Re: [2.0.0 Beta 1] login doesn't play nice with reverse proxy

Posted: September 1st, 2017, 6:22 pm
by E71
I hope what I'm about to say isn't impolite because it isn't my intention but... SAB was working fine before v2 so whatever changes were made, which resulted in absolute paths, could maybe be undone? Of course I don't know exactly was the original purpose of that change was and whether or not it accomplished it, but in the off chance that it didn't, undoing it should be somewhat straight-forward?

I think it was in interface.py and unfortunately I'm not familiar enough with Python to fully understand what's happening but I did notice references to '/login/' instead of just 'login/', etc.

Re: [2.0.0 Beta 1] login doesn't play nice with reverse proxy

Posted: September 1st, 2017, 6:27 pm
by safihre
The changes were substantial, removing the secondary webinterface and simplifying huge chunks of the code.

Have you tried 2.2.1? Because I did made some changes to not force full URLs, forgot which version that was introduced.

Re: [2.0.0 Beta 1] login doesn't play nice with reverse proxy

Posted: September 1st, 2017, 6:54 pm
by E71
Okay, if the changes to interface.py which resulted in this behavior effect other features then I guess we can't simply undo it and this is now officially a feature request.

I tried v2.2.1 about two hours ago and still the same thing happens, it redirects to /sabnzbd/login/ instead of /custom/path/to/sabnzbd/login/.

Re: [2.0.0 Beta 1] login doesn't play nice with reverse proxy

Posted: September 2nd, 2017, 4:21 am
by safihre
@E71
I implemented a new setting "base_path" setting where you can customize the "/sabnzbd" to what you want. It has to start with a "/" and you should restart after changing it.
Can you test and let me know if it's working for you? :)
https://github.com/sabnzbd/sabbuild/rel ... 0-basepath

Re: [2.0.0 Beta 1] login doesn't play nice with reverse proxy

Posted: September 2nd, 2017, 10:47 am
by E71
Thanks for that. Unfortunately, it didn't work for me.

Changed url_base setting directly via ini (since I cannot access GUI), to the same path as my apache rewrite and it results in a perpetual redirect loop.

Was expecting redirect to /my/custom/path/to/sab/login but it kept redirecting to the basepath itself.

(I'm assuming url_base is the base_path you added.)

Here's the relevant part of page source:

Code: Select all

<script type="text/javascript">
location.href = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '') + '/my/custom/path/to/sab' ;
</script>
sabnzbd.ini:

Code: Select all

url_base = /my/custom/path/to/sab
httpd.conf:

Code: Select all

<Location /my/custom/path/to/sab>
  order deny,allow
  deny from all
  allow from all
  ProxyPass http://localhost:12345/sabnzbd
  ProxyPassReverse http://localhost:12345/sabnzbd
</Location>

Re: [2.0.0 Beta 1] login doesn't play nice with reverse proxy

Posted: September 2nd, 2017, 11:08 am
by safihre
Change also the httpd.conf:

Code: Select all

ProxyPass http://localhost:12345/my/custom/path/to/sab
ProxyPassReverse http://localhost:12345/my/custom/path/to/sab

Or

Code: Select all

ProxyPass http://localhost:12345/
ProxyPassReverse http://localhost:12345/
Since SABnzbd binds to both / and /my/custom/path/to/sab