Configure CouchPotato Reverse Proxy nginx Mac OSX

nginx-couchpotato-reverse-pA Reverse proxy is a cool way to remotely access your media server's web interfaces. When you are done with this guide you will be able to use your free dynamic DNS address (Mac Afraid DNS Guide) like instead of This means fewer open ports on your router leaving you more secure while simultaneously having a convenient URL to access CouchPotato behind an nginx reverse proxy. This guide was tested on Mac OSX Mavericks but should work on any version like Mountain Lion or Yosemite.

Configure CouchPotato Reverse Proxy Mac OSX

Setup CouchPotato for a Reverse Proxy

To prepare CouchPotato for use in a reverse proxy, open up the webui at http://ip.address:5050

In the interface, go to Settings, click General, check off Show Advanced Settings

Scroll down to Url base and add /couchpotato.

You should add a username and password too for security

couchpotato reverse proxy set url base

Restarting CouchPotato is a good idea

Open Terminal and Install X-Code

Open up terminal which you can find Terminal in Applications -> Utilities

mac osx nzbdrone click utilities

Now Scroll down to Terminal and open it

mac osx nzbdrone click terminal

The Mac Terminal is nice and white.

mac nzbdrone terminal

Nginx requires command line tools on the Mac in order to compile nginx from source.
Install x-code tools with this command.

xcode-select --install

xcode install command line tools

You will get a pop up asking to install command line tools. Click Install.

xcode install command line developer tools

If it says it couldn't be found then you already have command line tools installed

command line developer tools already installed

Build nginx from Source for Mac OSX

Instructions adapted from Kevin Worthington's site

In the terminal (which is not that scary) all you have to do is copy and paste these commands.

We need to build PCRE which is a perl module first for nginx to use during building

Enter the Applications folder

cd /Applications

Create a directory for building

mkdir nginx

Enter directory for building

cd nginx

Download the latest Perl PCRE module


Extract the PCRE module

tar -xvf pcre-8.36.tar.gz

Enter the PCRE module

cd pcre-8.36

Configure the pcre module


Go up one directory level to /Applications/nginx

cd ..

Download nginx


Unpack nginx

tar -xvf nginx-1.6.2.tar.gz

Enter nginx folder

cd nginx-1.6.2

Configure nginx for compiling with pcre

sudo ./configure --prefix=/usr/local/nginx --with-cc-opt="-Wno-deprecated-declarations" --with-http_ssl_module --with-pcre=/Applications/nginx/pcre-8.36
sudo make
sudo make install

Start nginx

sudo /usr/local/nginx/sbin/nginx

Open up a browser and navigate to http://ip.address and you should see the default nginx page which looks like this
nginx welcome page mac osx

Time to create the CouchPotato reverse proxy on Mac OSX

Open the nginx configuration file

sudo nano /usr/local/nginx/conf/nginx.conf

Find this section and change your server_name localhost to your dynamic dns address and your media server's local IP address

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

Mine looks like this so I can access it locally and remotely. needs to be replaced with your own dynamic DNS address and needs to be replaced with your home media server's local IP address.

server {
        listen       80;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

Underneath the #access_log line, add these lines. points to the loopback address on your media server

location /couchpotato {
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

The whole section will now look like this

server {
        listen       80;
        location /couchpotato {
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Autostart nginx on boot using this plist upstart script thanks to Hunter

sudo nano /Library/LaunchDaemons/nginx.plist

Paste the working nginx plist code

<plist version="1.0">

You can also try http://ip.address/couchpotato and you should see the CouchPotato interface

You may delete the /Applications/nginx folder

In terminal this command will do it or you can use the GUI.

sudo rm -R /Applications/nginx

If you are running a Mac OSX version other than Mavericks, please let me know in the comments if this guide worked for you on another version.

Don't forget to forward port 80 on your router if you want to access the reverse proxy using dynamic DNS