NGINX multiple virtual hosts running on port 80

  • Hi,


    Since Let's Encrypt has recently launched wildcard certificates I've decided to set up a subdomain with wildcard certificate for all HTTP services on my LAN. Essentially I have an acme.sh client running as a cron job on a box, configured to perform DNS-based validation for the subdomain via Cloudflare API, renew the certificate and automatically deploy it to all services via SSH, this includes my router for the web-based admin interface, Proxmox and OMV. This allows me not to expose any services externally for domain validation, which is nice. So let's say the subdomain is lan.example.com and the certificate is for *.lan.example.com. My local DNS server is configured to resolve all lan.example.com hosts inside the LAN, OMV being omv.lan.example.com for example.


    Now, I figured I could also have separate hosts for all web services running on OMV aside from the admin UI, for example Transmission, so I installed the Nginx plug-in and tried to configure as reverse proxy with name-based server blocks. However, is there a way to have all these hostsreachable on port 443? For example my nginx configuration for transmission looks like this:



    This fails. Either the OMV UI stops responding or nginx fails to restart with multiple errors:
    Mar 18 21:32:16 omv nginx[17833]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
    Mar 18 21:32:16 omv nginx[17833]: nginx: [emerg] bind() to 0.0.0.0:443 failed (98: Address already in use)


    Is there any way to make this work with different hosts/websites on the same port? If I change the ports to something else, it works, but I'd really like to have clean URLs. For example I'd like https://omv.lan.example.com to point to the OMV UI, while https://torrent.lan.example.com to point to Transmission interface, even though they are both on the same machine/IP address.

  • Hmm. There appears to be a problem. If I apply some changes in the OMV UI, the Nginx plug-in adds the listen 443 ssl; directive back to the zzz-omv-nginx configuration file. This crashes the OMV UI. Maybe the plug-in doesn't have support for multiple services on the same port? Not sure. Do I even need the Nginx plug-in installed to achieve what I want?

  • I think I'm not doing something right:


    Even if I set Host Type as name-based in the Nginx plug-in, set the subdomain name, then I choose enable SSL, port 443 and "only use SSL" and save and apply settings, then I get an error and OMV UI dies. That's because the plug-in creates both listen directives creating conflict with the OMV UI which also runs on 443. Here is the config the plug-in generates (changed real domain name):



    If I manually edit the generated zzz-omv-nginx config file and delete the first IPv4 listen directive and leave only listen [::]:443 ssl; and restart nginx then it works. However, when I go back into OMV UI it will say I have unsaved settings (probably because of the manual edit) and if I save the settings it adds the listen 443 ssl; directive back, crashing the UI again. Not sure what I'm doing wrong.

Jetzt mitmachen!

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