<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>diginc &#187; Apache</title>
	<atom:link href="http://diginc.us/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://diginc.us</link>
	<description>\'dij-iŋk\</description>
	<lastBuildDate>Fri, 18 Jun 2010 20:17:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Ubuntu SABnzbd+ protected by an apache2 proxy and htpasswd</title>
		<link>http://diginc.us/2009/02/ubuntu-sabnzbd-protected-by-an-apache2-proxy-and-htpasswd/</link>
		<comments>http://diginc.us/2009/02/ubuntu-sabnzbd-protected-by-an-apache2-proxy-and-htpasswd/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 00:00:48 +0000</pubDate>
		<dc:creator>diginc</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[sabnzbd]]></category>
		<category><![CDATA[usenet]]></category>

		<guid isPermaLink="false">http://diginc.us/?p=35</guid>
		<description><![CDATA[Basic SABnzbd+ Setup &#8211; SAB for short. There are plenty of tutorials out there which cover configuring a normal SAB installation so I won&#8217;t cover that here. What I am going to do is make my SAB available through a &#8230; <a href="http://diginc.us/2009/02/ubuntu-sabnzbd-protected-by-an-apache2-proxy-and-htpasswd/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Basic SABnzbd+ Setup</strong> &#8211; SAB for short.</p>
<p>There are plenty of tutorials out there which cover configuring a normal SAB installation so I won&#8217;t cover that here.  What I am going to do is make my SAB available through a web accessible passworded page, this can be accomplished with default SAB features by putting a web username/password in the general configuration section.  However I find it annoying to have to enter the password when I&#8217;m on my internal 192.168 home network just to make it protected from the outside, and I don&#8217;t like the way it presents the username/password prompt in a website form rather than an generic apache pop-up.  I&#8217;m sure open accessibility could be fixed in the SABnzbd+ code but I&#8217;m not a pro python hacker yet so I&#8217;ll just stick to what I know.</p>
<p>Basically I want a generic pop-up password that is only for people outside my network so I&#8217;m not bothered with SAB passwords while at home (And I can&#8217;t get <a href="https://nzbdstatus.bountysource.com/">nzbdStatus</a> to work with a pass enabled).  The htpasswd also acts as a bit of camouflage and additional security.  There are some concepts which aren&#8217;t covered here which are required, you need to know how to configure your own SAB servers, Portforwarding or Firewall/iptables.</p>
<p>If you&#8217;re using a router, you&#8217;re going to want to make sure you&#8217;re not port forwarding the default SAB port of 8080 (which would make it wide open) and only are forwarding the apache2 port you setup for the SAB proxy.  If you&#8217;re not on an internal IP subnet and have a static IP assigned directly to the linux machine you&#8217;re doing this on then I expect you have enough knowledge of IPTables to block the SAB port and allow the proxy port.</p>
<p><span id="more-35"></span></p>
<p><strong>SABnzbd Daemon (optional)</strong></p>
<p>Download the latest SABnzbd version from http://www.sabnzbd.org/download/ to your favorite place to install python apps and optionally install a deamon to auto start SAB: <a href="http://artur.hefczyc.net/node/10">http://artur.hefczyc.net/node/10</a>.  Mine is modified to include a restart command:</p>
<p><code><br />
#!/bin/sh<br />
# Source: http://sabnzbd.wikidot.com/install-as-a-unix-daemon<br />
case "$1" in<br />
start)<br />
echo "Starting SABnzbd."<br />
/usr/bin/sudo -u sabuser -H /usr/local/src/SABnzbd/SABnzbd.py -d -f /home/sabuser/.sabnzbd/sabnzbd.ini<br />
;;<br />
stop)<br />
echo "Shutting down SABnzbd."<br />
/usr/bin/wget -q --delete-after "http://localhost:8080/sabnzbd/api?mode=shutdown"<br />
;;<br />
restart)<br />
$0 stop<br />
$0 start<br />
;;<br />
*)<br />
echo "Usage: $0 {start|stop|restart}"<br />
exit 1<br />
esac<br />
exit 0<br />
</code><br />
At this point I&#8217;ll assume you have a working sabnzbd installation and have tested to confirm it&#8217;s working.</p>
<p><code>vi /home/sabuser/.sabnzbd/sabnzbd.ini</code><br />
Change <code>host = localhost</code> to <code>host = 192.168.0.53</code> to make it accessible from elsewhere besides the box running SAB.<br />
That&#8217;s all you need to do with SAB other than configure servers and preferences.</p>
<p><strong>Apache Proxy Setup</strong><br />
<code><br />
apt-get install apache2<br />
htpasswd -c /usr/local/src/SABnzbd/.htpasswd username # Enter your password when prompted<br />
a2enmod proxy<br />
a2enmod proxy_http<br />
a2enmod proxy_html</code></p>
<p>Ubuntu mod_proxy Denies all but default so you&#8217;ll need to make a similar modification to what follows &#8211; see your Apache error files for something like  if your proxy isn&#8217;t working.  You can either change <code>Deny from all</code> to <code>Allow from all</code> if you expect to be using it from any external IP address or individual IPs you&#8217;ll expect needing access (work IP).  In my case 192.168.0.1 port forwards so that&#8217;s the only one I need but I put in my entire internal subnet for testing purposes.<br />
<code>vi /etc/apache2/mods-enabled/proxy.conf</code><br />
<code>&lt;Proxy *&gt;<br />
  AddDefaultCharset off<br />
  Order deny,allow<br />
  Deny from all<br />
  Allow from 192.168.0.0/24<br />
&lt;Proxy&gt;</code></p>
<p>Add something like this to your apache2 vhost config (logs are optional)<br />
<code>vi /etc/apache2/conf.d/vhosts.conf</code><br />
<code><br />
Listen 8001 # Use whatever port you want, I usually use obscure ports that aren't regularly scanned.<br />
NameVirtualHost 192.168.0.53:8001  # Change 192.168.0.53 to whatever your SAB server's IP is (make sure it's static too).<br />
</code><code><br />
&lt;VirtualHost 192.168.0.53:8001&gt;<br />
ServerName sabuser.dyndns.org # Enter your hostname or <strong>static</strong> IP address here.  I use dyndns.org since I have a dynamic IP<br />
ProxyPass /sabnzbd http://192.168.0.53:8080/sabnzbd/<br />
ProxyPassReverse /sabnzbd http://192.168.0.53:8080/sabnzbd/<br />
ProxyPreserveHost On<br />
# Password Protect the external proxy only.<br />
&lt;Location /sabnzbd&gt;<br />
AuthUserFile /usr/local/src/SABnzbd/.htpasswd<br />
AuthName "Authenticate Yourself."<br />
AuthType Basic<br />
Require valid-user<br />
&lt;/Location&gt;<br />
# Alternate method, requires rewrite mod:<br />
#RewriteEngine   on<br />
#RewriteRule     (.*) http://192.168.0.53:8080/sabnzbd/$1 [P]<br />
&lt;/VirtualHost&gt;<br />
</code></p>
<p>References</p>
<p># Apache Proxy<br />
<a href="http://snippets.dzone.com/posts/show/1318">http://snippets.dzone.com/posts/show/1318</a><br />
<a href="http://mail-archives.apache.org/mod_mbox/httpd-users/200307.mbox/%3C20030723191854.43885.qmail@web40903.mail.yahoo.com%3E">http://mail-archives.apache.org/mod_mbox/httpd-users/200307.mbox/%3C20030723191854.43885.qmail@web40903.mail.yahoo.com%3E</a><br />
<a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html">http://httpd.apache.org/docs/2.2/mod/mod_proxy.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://diginc.us/2009/02/ubuntu-sabnzbd-protected-by-an-apache2-proxy-and-htpasswd/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
