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

Questions and bug reports for Beta releases should be posted here.
Forum rules
Help us help you:
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
sleepblanket
Newbie
Newbie
Posts: 2
Joined: March 11th, 2017, 6:03 am

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

Post 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.
Robius
Newbie
Newbie
Posts: 3
Joined: March 11th, 2017, 6:15 am

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

Post 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;
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

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

Post by safihre »

What do you expect?
Of course it will direct from /sabnzbd/login and then back to /sabnzbd, what else?
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
sleepblanket
Newbie
Newbie
Posts: 2
Joined: March 11th, 2017, 6:03 am

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

Post 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
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

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

Post 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.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
brdhse1
Newbie
Newbie
Posts: 1
Joined: May 28th, 2017, 9:09 am

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

Post 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?
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

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

Post 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.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
User avatar
E71
Newbie
Newbie
Posts: 42
Joined: January 13th, 2009, 10:08 pm

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

Post 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.
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

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

Post 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 :)
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
User avatar
E71
Newbie
Newbie
Posts: 42
Joined: January 13th, 2009, 10:08 pm

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

Post 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.
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

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

Post 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.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
User avatar
E71
Newbie
Newbie
Posts: 42
Joined: January 13th, 2009, 10:08 pm

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

Post 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/.
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

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

Post 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
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
User avatar
E71
Newbie
Newbie
Posts: 42
Joined: January 13th, 2009, 10:08 pm

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

Post 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>
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

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

Post 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
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
Post Reply