Daemon webUI access through hostname/prefix [Nginx] [Proxy_pass]
Introduction
Several daemons in OMV have their own webUI running in their own http engine, for example if we want to access Sickbeard we type in the browser URL http://omv_ip:8081/ for transmission-daemon we type http://omv_ip:9091/transmission/web/ and so on.
This guide is about using the Nginx (default OMV http engine) to make use of proxy_pass which will allow us to use hostnames or local domain prefixes in port 80 to access those services without affecting OMV user interface. This works by redirecting specific domain/hostnames request to the necessary port.
Now for example if we want to access sickbeard, let’s invent a short name say http://sb.lan (.lan is my local domain pushed to every client by my router LAN dns)
Cups,
cups.png
Transmission,
td.png
Pre-Requirements
OpenMediaVault 1.0
Also, for this you will require to be in control of your DNS local resolver (dnsmasq let that be in openwrt, tomato or ddwrt) that will allow you to point multiple hostnames or prefixes to one IP in your LAN. If your router can assign multiple hostnames to one ip then is also possible.
Setup
Now let’s get into it, for this will need ssh access console. Let’s create a text file in /etc/nginx/sites-available/, this file will hold our multiple hosts settings
nano /etc/nginx/sites-available/multi_host
From there let’s put our first entry for sickbeard:
#sickbeard
server {
server_name sb.lan;
listen [::]:80;
location / {
proxy_pass http://localhost:8081/;
}
}
Let's add Cups
#cups
server {
server_name cups.lan;
listen [::]:80;
location / {
proxy_pass http://localhost:631/;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Alles anzeigen
transmission daemon
#transmissiion-dameon
server {
server_name td.lan;
listen [::]:80;
location / {
proxy_pass_header X-Transmission-Session-Id;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:9091;
}
}
Alles anzeigen
Once were finish, nginx will read the file from sites-enabled folder, so for that:
ln –s /etc/nginx/sites-available/multi_host /etc/nginx/sites-enabled/multi_host
Then we restart the nginx daemon
/etc/init.d/nginx restart.
Nginx will cluck for any syntax error, watch for the semicolons at the end of lines in between the curly brackets, if there’s any missing correct.
Please notice that every service/daemon is somehow different depending on how their http server configured. Most of this configurations contributed here were done by trial and error, reading nginx documentation website and some other forums. I am not an Nginx ninja so every person that knows more and wants to contribute with custom settings is more than welcomed.
The best way to achieve this without a local dns server is to use the syntax http://omv_hostname/sickbeard but I haven't been able to figure it out yet.
Don’t have a local DNS?
We can circumvent around this in every client in our LAN that we want to give access by modifying the host file.
In windows:
C:\Windows\System32\Drivers\etc\hosts
Linux and Mac OS X:
/etc/hosts
There we can add a line like this line:
ip_address_OMV hostname_desired
example:
10.10.10.12 cups.lan
In the attachment section you will find a txt file with all daemons settings I use for my OMV. Please feel free to take it an accommodate it to your own needs.
Edit: added dockerUI in the spoiler below
server {
server_name docker.lan;
listen [::]:80;
location / {
proxy_pass http://localhost:9200/;
proxy_http_version 1.1;
proxy_set_header Connection "";
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;
proxy_set_header X-Forwarded-Host $server_name;
}
}
Alles anzeigen
EDIT: For omv 3.0 onwards we should add an additional listen line for each block, so for example for sonarr
#Sonarr
server {
server_name drone.lan;
listen 80;
listen [::]:80;
location / {
proxy_pass http://localhost:8989;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Alles anzeigen
Questions / Problems / Diskussions
Click HERE to get to the discussions thread.