Configure NZBGet Reverse Proxy nginx Linux

A reverse proxy is a secure method of remotely accessing services on your home media server. Using nginx on any Linux based system (Ubuntu, Debian, Raspbian) you can access NZBGet without having to remember the port number inside your home network. With a free dynamic dns address (guides: Linux, Raspbian) you can manage NZBGet at your friend's house at a custom address like htpcguides.crabdance.com/nzbget. It is very convenient and easy to set up once you know how, it will add that extra bit of awesomeness to your HTPC media server. This guide was tested on Raspbian but should work on any Linux based system. I assume you know what your IP address is and how to SSH in to your Linux box.

Configure NZBGet Reverse Proxy nginx Linux

Update your repositories

sudo apt-get update

Install nginx

sudo apt-get install nginx -y

Create a new nginx site

sudo nano /etc/nginx/sites-available/reverse

Add these lines, adjust your dynamic dns address (mine is htpcguides.crabdance.com) and local IP address (mine is 192.168.40.105. If you changed your default NZBGet port change 127.0.0.1:6789 to reflect your port. If you already have some reverse proxy locations set up, you do not need to add the server block, only the location /nzbget section including the blue curly brackets.

You must use the location /nzbget as NZBGet does not currently support custom web roots.

server {
listen 80;
server_name htpcguides.crabdance.com 192.168.40.105;

location /nzbget {
    proxy_pass http://127.0.0.1:6789;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

Ctrl+X, Y and enter to save and exit

Disable the default nginx site

sudo unlink /etc/nginx/sites-enabled/default

Enable the reverse proxy site with nzbget enabled

sudo ln -s /etc/nginx/sites-available/reverse /etc/nginx/sites-enabled/reverse

Test nginx to make sure your configuration has the correct syntax

sudo nginx -t

Restart the nginx service if the test showed no errors

sudo service nginx restart

You can now access NZBGet locally within your home network at http://ip.address/nzbget.

If you have a dynamic DNS addresss you can access NZBGet outside your home network at http://yourdns.address/nzbget

To access it outside the home network you will need to forward port 80 in your router to the machine hosting nginx.

If you get a 502 Bad gateway error it may be because you are on a Raspberry Pi or slow machine, give it a few minutes to load the NZBGet web interface.

Enjoy your safe, secure nginx reverse proxy for NZBGet. You can now close port 6789 on your router if you had it forwarded before.

If you want reverse proxy brute force protection using fail2ban see this guide.