Limiting WebUI to primary IP Address

  • For purposes beyond this thread, I have a need to run a Docker on port 80 on an additional IP Address on my OMV server. I can easily add an additional IP Address:

    Code
    ifconfig eth0:1 192.168.2.7


    However, everytime I attempt to run my Docker using this IP Address and Port, I get the following error:

    Code
    root@NAS:/# docker run -it --name magneto --link magnetodb:db -p 192.168.2.7:80:80 byteme/website
    Error response from daemon: Cannot start container 28eb288b4b1f59053312b6ff53900266cf435642b0fcc92850c0eb8c76002e6b: failed to create endpoint magneto on network bridge: Error starting userland proxy: listen tcp 192.168.2.7:80: bind: address already in use


    Basically, Docker is telling me that something is using port 80 on my secondary IP Address. Some careful snooping revealed that Nginx is setup with two suspect lines:

    Code
    listen [::]:80 default_server ipv6only=off;
    ...
    listen [::]:443 default_server ipv6only=off ssl deferred;


    Yes, I can go in and play with the openmediavault-webgui file, but I'd prefer to treat this box like an appliance, and rely on it's built in logic and customization before going around and bastardizing my own server.


    So the questions are:
    1) Whats the best way to add a new IP Address to the OMV server without hacking underlying configurations?
    2) Whats the best way to limit the WebUI to the primary IP Address (again) without hacking underlying configurations?

    • Offizieller Beitrag

    ) Whats the best way to add a new IP Address to the OMV server without hacking underlying configurations?


    When the webUI does not provide configuration options, you need to use OMV environmental variables. Unfortunately for your case there is none that can solve your problem regarding NGNIX. This is the case where you don't want omv to rewrite the configuration every time you make a change. You can find the list here http://wiki.openmediavault.org…Environment_Variables/all
    Maybe you can fill a feature request at bugtracker to have an option to put nginx to listen only on certain interfaces or add a env variable that power users can modify.


    Have you ever heard or use a reverse proxy? if you know it, doesn't that solve your issue?

  • In this particular case, OMV (native from the ISO) *did not* support reverse proxy ... or any additional NGinx websites listening on port 80/443.


    I added a new site into /etc/nginx/sites-available and sym-linked it into /etc/nginx/sites-enabled. When I restarted nginx, I received the following error. I tried configuring the site to listen on port 80, a FQDN on port 80, and an IP Address on port 80. All presented with the same error message upon restart of NGinx.


    Code
    2016/01/17 22:54:41 [emerg] 22173#0: bind() to 0.0.0.0:80 failed (98: Address already in use)


    I found the answer on StackOverflow (http://stackoverflow.com/quest…98-address-already-in-use). Apparently, if you are listening to IPv4 and IPv6 with a listen directive, you need to split the listen into two separate lines on the default server.


    So, the line in the openmediavault configuration:

    Code
    listen [::]:80 default_server ipv6only=off;


    needs to become:

    Code
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;


    This was a default OMV out of the box - prior to this change, I had not done anything to the configuration. That leads me to think that OMV doesn't play nice with other sites on the base instance of NGinx without this tweak. But I could be wrong ... here's my new NGinx site if someone wants to check my configuration:


Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!