How to have Newznab behind a Apache reverse proxy

I spent a considerable amount of time trying to figure out how to get Newznab behind a Apache reverse proxy. Unlike SABnzbd, Sickbeard, CouchPotato or Headphones there was no web_root, url_base or http_root for Newznab to use with a reverse proxy. Just with my luck too, there is very little documentation available online on this subject.
 
So after reading a ton of Apache whitepapers, I found the alias command and alas had a solution that works time and time again. I tested everything on Ubuntu Servers running version 12.10(Quantal).
 
There is really only three pieces to this,

  • A frontend Apache reverse proxy.
  • A backend Apache server running Newznab.
  • Your .htaccess in the wwwroot of the Newznab server.

Prerequisites



 
If you already have your Apache installed/setup and your SSL certicates in place, you can skip this step.
 
Apache Installation:

 
Self signed SSL certificates creation:

Basic Configuration



 
Frontend Apache reverse proxy and it's VirtualHost config in /etc/apache2/sites-available/newznab.publicdomain.com:

Backend Apache actually running Newznab and it's VirtualHost config in /etc/apache2/sites-available/newznab:

.htaccess in the wwwroot of your actual Newznab server /var/www/newznab/www/.htaccess:

Advance Configuration



 
Now I personally like stepping it up a bit with my configurations, so if you feel the urge you're more than welcome to join me. In these configurations, I always use HTTPS/SSL (even to my backend servers). I also use publicly signed SSL certificate for my frontend reverse proxy and self signed SSL certificates for all my backend servers. Lastly, I always want to use HTTPS... so I use a rewrite rule to step up to HTTPS from HTTP.
 
Frontend Apache reverse proxy and it's VirtualHost config in /etc/apache2/sites-available/proxy.publicdomain.com:

Backend Apache actually running Newznab and it's VirtualHost config in /etc/apache2/sites-available/newznab:

.htaccess in the wwwroot of your actual Newznab server /var/www/newznab/www/.htaccess:

Optional Configuration



 
For those of you looking or interested in my VirtualHost configuration for my SABnzbd, Sickbeard, CouchPotato and Headphones server. Here is what I used to add them behind my reverse proxy.

For SickBeard, CouchPotato and Headphones you'll need to make three small changes while the services are STOPPED.
 
SickBeard

 
CouchPotato

 
Headphones

Conclusion



If you're like me and go with the more advance configuration and the optional setup. You can now browse any of the following URLs.

  • proxy.publicdomain.com/newznab
  • proxy.publicdomain.com/sabnzbd
  • proxy.publicdomain.com/sickbeard
  • proxy.publicdomain.com/couchpotato
  • proxy.publicdomain.com/headphones

Plus you don't have to remember to type the HTTPS because of your new Apache rewrite rules that will automatically add HTTPS for you or your users!

4 Comments

  1. Pat says:

    I've got a question about newznab.
    I've got apache setup as SSL proxy, to a non SSL newznab.

    some things don't quite work on the site, any ideas?

    Reply
  2. crosseye says:

    How is your Newznab SABnzbd Integration setup? Is Newznab and SABnzbd on the same server?

    For me they are on different servers, so I went to my Profile on Newznab and edited it to have the URL of my SABnzbd server to be https://hostname.domain.local/sabnzbd/ and entered my Nzb API key (doesn't need full contol) for SABnzbd. Also I made the Storage method Site, so I can login from anywhere and use the Send to Sab feature.

    That did the trick for me and now I'm able to use Send to Sab internally and externally. let me know if that helps.

    Reply
  3. tatonka says:

    Hi,

    i have added exactly the same configuration, however, the login form is redirecting me to https://tld/newznab/newznab which obviously can't be found. However, when i edit the URL in the address bar and remove the second newznab, it loads fine, and i am logged in.
    Do you know a solution of how to modify the login form to redirect me to https://tld/newznab instead of /newznab/newznab?

    Reply
    • crosseye says:

      Hey Tatonka,

      Let's break it down and do a little testing.

      For your backend Apache server VirtualHost config use,

      Also for your Newznab .htaccess config use,

      Once you complete the above changes reload Apache by,

      If you still experiance the problem but with a URL of https://domain.com/test/newznab instead, then there is most likely a problem with your Newznab site settings. So login to your Newznab server and check under Admin > Edit Site and then check the Default Home Page and make sure it's just "/" without the quotes. My guess is maybe you have it set to "/newznab".

      Please let me know if any of this fixes your problem.

      Reply

Leave a Comment

  • Info

    I typically try and keep the blog up-to-date but apparently I'm not very good at posting!