I am a big user of FREENAS and the goal behind this was to have one domain and to redirect the requests for my jails using, “jails/sickrage”, “jails/sonarr”, etc…

In order to do this, what you need to do is get an nginx server up and running. For this, I simply created a Linux Jail template and installed nginx.

This post makes the assumptions that you are using FREENAS, you are proficient in using vi or nano and that your jails are properly configured to handle reverse proxies, if not, I can do a guide on this in the future for the things you’ll need to configure for them to work correctly and you know how to set up a custom jail.

On your nginx server, locate the nginx.conf file. You can do this by using the find command in Linux but for me this file is located in /usr/local/etc/nginx, this may vary on the distribution that you use.
Now edit this file with your editor of choice.

Locate the following line: server {
Specify a server_name in my case, I named it jails.

Underneath this line type include proxy_setup.conf; (you could do the below all in the nginx.conf file but this way it’s cleaner.)

Now save and exit this file.

Now we will create a file named proxy_setup.conf in the current directory.

The general rule with this file is as follows:

    location /couchpotato {
     proxy_pass http://192.168.0.101:5050;
     proxy_redirect off;
     proxy_set_header Host $host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     }

     location /sickrage {
     proxy_pass https://192.168.0.102:8081;
     proxy_redirect off;
     proxy_set_header Host $host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     }

     location /web {
     proxy_pass http://192.168.0.103:32400;
     proxy_redirect off;
     proxy_set_header Host $host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     }

     location /ntopng {
     proxy_pass https://192.168.0.1:3000;
     proxy_redirect off;
     proxy_set_header Host $host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     }

     location /sonarr {
     proxy_pass http://192.168.0.105:8989;
     proxy_redirect off;
     proxy_set_header Host $host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     }

     location /sabnzbd {
     proxy_pass http://192.168.0.106:8080;
     proxy_redirect off;
     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 parts that you will need to change is proxy_pass and location.

This is my current working configuration. Remember, you will need to configure the jails to handle reverse proxies otherwise they won’t work. Generally, you just need to go into the .ini file of the jails and change handle_reverse_proxy = 0 to handle_reverse_proxy = 1 and to change the URL base/web root of the jail to match that of the location specified in your proxy file that points to that jail.

Enjoy not having to remember the IPs and Port numbers for each of your jails 🙂

Nathan

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.