Daemon webUI access through prefix/hostname [Nginx] [Proxy_pass]

    • OMV 1.0
    • core

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Daemon webUI access through prefix/hostname [Nginx] [Proxy_pass]

      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)

      sb.png

      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.

      wrt.png

      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:

      Source Code

      1. #sickbeard
      2. server {
      3. server_name sb.lan;
      4. listen [::]:80;
      5. location / {
      6. proxy_pass http://localhost:8081/;
      7. }
      8. }



      Let's add Cups

      Source Code

      1. #cups
      2. server {
      3. server_name cups.lan;
      4. listen [::]:80;
      5. location / {
      6. proxy_pass http://localhost:631/;
      7. proxy_set_header X-Forwarded-Host $host;
      8. proxy_set_header X-Forwarded-Server $host;
      9. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      10. }
      11. }
      Display All


      transmission daemon

      Source Code

      1. #transmissiion-dameon
      2. server {
      3. server_name td.lan;
      4. listen [::]:80;
      5. location / {
      6. proxy_pass_header X-Transmission-Session-Id;
      7. proxy_set_header X-Forwarded-Host $host;
      8. proxy_set_header X-Forwarded-Server $host;
      9. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      10. proxy_pass http://localhost:9091;
      11. }
      12. }
      Display All


      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.

      console.png

      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

      Display Spoiler

      Source Code

      1. server {
      2. server_name docker.lan;
      3. listen [::]:80;
      4. location / {
      5. proxy_pass http://localhost:9200/;
      6. proxy_http_version 1.1;
      7. proxy_set_header Connection "";
      8. proxy_redirect off;
      9. proxy_set_header Host $host;
      10. proxy_set_header X-Real-IP $remote_addr;
      11. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      12. proxy_set_header X-Forwarded-Host $server_name;
      13. }
      14. }
      Display All



      EDIT: For omv 3.0 onwards we should add an additional listen line for each block, so for example for sonarr


      Source Code

      1. #Sonarr
      2. server {
      3. server_name drone.lan;
      4. listen 80;
      5. listen [::]:80;
      6. location / {
      7. proxy_pass http://localhost:8989;
      8. proxy_buffering off;
      9. proxy_set_header Host $host;
      10. proxy_set_header X-Real-IP $remote_addr;
      11. }
      12. }
      Display All



      Questions / Problems / Diskussions
      Click HERE to get to the discussions thread.
      Files
      • multi_host.txt

        (2.12 kB, downloaded 127 times, last: )
      New wiki
      chat support at #openmediavault@freenode IRC | Spanish & English | GMT+10
      telegram.me/openmediavault broadcast channel
      openmediavault discord server

      The post was edited 18 times, last by subzero79 ().