sabnzbd and apache2

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • 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.
Post Reply
emarkd
Newbie
Newbie
Posts: 6
Joined: January 31st, 2008, 11:33 pm

sabnzbd and apache2

Post by emarkd »

I really want to hide sabnzbd and it's cherrypy server behind my apache2 installation, but I can't seem to get it working.  I've read the very limited docs available from cherrypy about using mod_rewrite, but they're not in-depth enough.  I keep getting protocol handler errors.  On the other end is the apache docs that go way more in depth than I need and I can't find what I need in all that information.  Can anyone who has this working point me in the right direction?  Is there a good tutorial out there that I'm missing?
User avatar
switch
Moderator
Moderator
Posts: 1380
Joined: January 17th, 2008, 3:55 pm
Location: UK

Re: sabnzbd and apache2

Post by switch »

I assume you mean these tutorials: http://tools.cherrypy.org/wiki/BehindApache yes?

Try using this way, it looks easier: http://sourceforge.net/forum/message.php?msg_id=4712352

Sorry I can't be of more help, never set sab up behind apache.
emarkd
Newbie
Newbie
Posts: 6
Joined: January 31st, 2008, 11:33 pm

Re: sabnzbd and apache2

Post by emarkd »

Thanks for your reply and interest in my question.  I tried it using only mod_proxy as well and it wouldn't work for me.  I just get the html, no CSS or JS makes it through.  I've made a bit of progress, though.  Using the mod_rewrite module, I've written these two simple rules for the redirection:

RewriteRule ^/nzb$ http://localhost:8080/sabnzbd/ [P]
RewriteRule ^/nzb/$ http://localhost:8080/sabnzbd/ [P]

They're supposed to redirect any traffic to my server at /nzb to the CherryPy server in the background by funneling it through mod_proxy.  It works just like using mod_proxy without the rewrite.  I get the html, but no CSS or JS.  If I change those flags to [R], then it skips the mod_proxy and does a real redirect.  That works fine and I may just consider it good enough if I can't get mod_proxy to play nice, but then I have to open port 8080 to the outside and I really didn't want to.

Anybody have any ideas?
Last edited by emarkd on February 1st, 2008, 10:27 am, edited 1 time in total.
User avatar
switch
Moderator
Moderator
Posts: 1380
Joined: January 17th, 2008, 3:55 pm
Location: UK

Re: sabnzbd and apache2

Post by switch »

Been a long time since I have messed around with mod_rewrite, but mayb add this in?

RewriteRule ^/nzb/$ http://localhost:8080/sabnzbd/$1 [P]
emarkd
Newbie
Newbie
Posts: 6
Joined: January 31st, 2008, 11:33 pm

Re: sabnzbd and apache2

Post by emarkd »

Thanks again for the suggestion, but that didn't get it either.  In my poking around, though, I've uncovered some new information.  I didn't think about my sab login cookie earlier and when I clear that cookie, things change a bit.

When I go to /nzb on my apache server, it actually shows the login fine (I know there's no CSS or anything there), but when I enter my credentials, I get a 404 /sabnzbd/ not found, so it's like CherryPy is redirecting me again somehow.  So I changed my rules to use /sabnzbd as the root on apache to try and cover up the redirect.  Now when I go to /sabnzbd on apache, I get the login screen from CherryPy and after logging in it redirects me to sab, but still with no CSS or JS.  Do I have to do something to CherryPy or SAB to make this work?
emarkd
Newbie
Newbie
Posts: 6
Joined: January 31st, 2008, 11:33 pm

Re: sabnzbd and apache2

Post by emarkd »

Thanks, but that's not it either.  I tried both Plush and the default and they both give just HTML through the proxy.  Going directly to CherryPy works fine every time.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: sabnzbd and apache2

Post by shypike »

This is what I have in my Apache 2.2 setup to handle SABnzbd.
Not quite sure which parts are specific for SAB and I may have enabled additional Apache modules.

http://sabnzbd.wikidot.com/howto-apache
Last edited by shypike on December 7th, 2008, 3:20 pm, edited 1 time in total.
emarkd
Newbie
Newbie
Posts: 6
Joined: January 31st, 2008, 11:33 pm

Re: sabnzbd and apache2

Post by emarkd »

Thanks a lot!  That works great and it's much simpler than what I was trying to do.  That makes SAB, which is already great, that much more useful.  I appreciate everyone's help on this.
User avatar
mantis006
Release Testers
Release Testers
Posts: 17
Joined: January 28th, 2008, 5:06 am
Contact:

Re: sabnzbd and apache2

Post by mantis006 »

The way I do it is by utilizing mod_proxy in apache.  I setup a vhost to handle a lot of my "LAN only services" like sab.  By doing this, you'll be able to utilize all those wonderful apache authentication and security modules (SSL, AUTH_MYSQL, etc) to really secure your sabnzbd web interface.

I run Apache/2.2.9 on Gentoo Linux.  Any of this stuff can just be thrown in httpd.conf; but, modular config files tend to be cleaner

/etc/apache2/vhosts.d/00_default_vhost.conf

Code: Select all

...
<VirtualHost *:80>
    Include /etc/apache2/vhosts.d/admin_vhost.include
</VirtualHost>
...
/etc/apache2/vhosts.d/admin_vhost.include

Code: Select all

... #declare all that good stuff for vhost, this below part is the meat and potatoes for this discussion
<IfDefine PROXY> #passed with a -D parameter to the server daemon, check your init/conf script to see where to put this
    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass    /sabnzbd/ http://localhost:8080/sabnzbd/
    
    <Location /sabnzbd/>
        #some authentication stuff, nothing too special - just some simple stuff like passwd file locaitons, group file locations, etc
        Include /etc/apache2/modules.d/basic_auth.include
        AuthName "whatever you want the prompt to say..."
        require group sabnzbd # or just valid-user, as i said-doesn't matter

        ProxyPassReverse http://localhost:8080/sabnzbd/
    </Location>
</IfDefine>
...
So that's the fun part.  This is just a common question i see thrown around an awful lot with regards to web UIs so I figured I'd just post my findings SOMEWHERE...

Hope that helps someone.
~Chris
methanoid
Jr. Member
Jr. Member
Posts: 66
Joined: March 7th, 2008, 6:33 am

Re: sabnzbd and apache2

Post by methanoid »

I'm trying to get the same effect (SAB running behind Apache).... but running Apache for Windows. Just done a standard install and popped the text at the bottom of httpd.conf

ProxyRequests On
ProxyVia On


Order deny,allow
Deny from all
Allow from all



order deny,allow
deny from all
allow from all
ProxyPass http://localhost:8088/sabnzbd
ProxyPassReverse http://localhost:8088/sabnzbd



EDIT: mod_proxy.so has to be enabled also... spotted that (I'm using Windows Apache)... but it does nothing!!
Last edited by methanoid on December 7th, 2008, 12:17 pm, edited 1 time in total.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: sabnzbd and apache2

Post by shypike »

Don't use this particular setup, you'll end up running an anonymous proxy.

Use this setup:
http://sabnzbd.wikidot.com/howto-apache

BTW: this was only tested on Ubuntu.
methanoid
Jr. Member
Jr. Member
Posts: 66
Joined: March 7th, 2008, 6:33 am

Re: sabnzbd and apache2

Post by methanoid »

shypike wrote: Don't use this particular setup, you'll end up running an anonymous proxy.

Use this setup:
http://sabnzbd.wikidot.com/howto-apache

BTW: this was only tested on Ubuntu.
well that link didnt work either....or the procedure.

First off you need to load Mod_Proxy and co... I *think* these

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

ProxyRequests Off


order deny,allow
deny from all
allow from all
ProxyPass http://localhost:32768/gui
ProxyPassReverse http://localhost:32768/gui



order deny,allow
deny from all
allow from all
ProxyPass http://localhost:9000/sabnzbd
ProxyPassReverse http://localhost:9000/sabnzbd



The code worked perfectly for running utorrent (obviously different port numbers and hardcoded URL is /gui) but for SABnzbd it gives me a 503 error all the time

"Service Temporarily Unavailable"

I get that if I type
http://192.168.0.208/sabnzbd/
http://localhost/sabnzbd/
http://webaddress.com/sabnzbd/
http://192.168.0.208/sabnzbd
http://localhost/sabnzbd
http://webaddress.com/sabnzbd

Any ideas?
methanoid
Jr. Member
Jr. Member
Posts: 66
Joined: March 7th, 2008, 6:33 am

Re: sabnzbd and apache2

Post by methanoid »

Thanks to Shy for the email. It didnt work but made me look again at the issue. If I had used my head I would have looked in the LOG and seen it was refusing a localhost connection. So I replaced with IP address and it works fine. Strange, I can use localhost for uTorrent but SAB needed a specific IP addy. Oh well.. it works which is all that matters to me!!!  ;D

For the record;

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so

ProxyRequests Off

#
#order deny,allow
#deny from all
#allow from all
#ProxyPass http://localhost:32768/gui
#ProxyPassReverse http://localhost:32768/gui
#


order deny,allow
deny from all
allow from all
ProxyPass http://192.168.0.208:9000/sabnzbd
ProxyPassReverse http://192.168.0.208:9000/sabnzbd


(and making sure ServerName is defined and file locations earlier in the conf)
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: sabnzbd and apache2

Post by shypike »

methanoid wrote: I can use localhost for uTorrent but SAB needed a specific IP addy. Oh well.. it works which is all that matters to me!!!  ;D
Weird, I have my SABnzbd running on localhost all the time.
Post Reply