nginx-proxy-manager icon indicating copy to clipboard operation
nginx-proxy-manager copied to clipboard

Change NPM Listen port based on Proxy Host

Open CrazyVaclav opened this issue 2 years ago • 6 comments

Hi, I have two proxy hosts in my NPM docker container: I.) Public Website and therefore Port 80 and 443 should be used for NPM to listen on and forward to port 80 of the target HTTP Joomla app. I want that this app is accessible with port 80 and 443 II.) Private self build web app that only I will access. I want that this second proxy host is ONLY accessible via Port 8443

In my docker compose file I created a Host:Container Mapping for all three ports:

    ports:
      # These ports are in format <host-port>:<container-port>
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '8443:8443' # Private HTTPS Port
      - '81:81' # Admin Web Port

What I can do so far is add listen 8443 ssl http2; to the Advanced Tab in the target proxy host number II image

That opens up Port 8443 for the proxy host number I and II. and Port 443 is still open for proxy host number I and II.

Is there a way to change the default 443/80 listen ports of NPM ONLY for proxy host number II ?

CrazyVaclav avatar May 31 '23 21:05 CrazyVaclav

I have exactly the same issue, its possible to remove 80/443 in the XX.conf file manual. then just change a different config to restart nginx, but will be added from ui again after some changes on the host config. so its not really a persistent solution.

it would be really nice to have the option to comment out the default listening in a config by a checkbox/switch, to be able to listen only on custom ports inside the advanced config and not the default 80/443 set.

zer0brain avatar Aug 29 '23 12:08 zer0brain

So i found meanwhile a workaround to make it persistent. Iadded an additional mount point for the /app/template Folder

-data/docker/local/npm/letsencrypt:/etc/letsencrypt
- /data/docker/local/npm/templates:/app/templates

Then added the content Manual from here: https://github.com/NginxProxyManager/nginx-proxy-manager/tree/develop/backend/templates

then change the template _listen.conf added # everywhere to not listen on anything in any case.

listen 11111;  # << Random not mapped port 
{% if ipv6 -%} 
#listen [::]:80; 
{% else -%} 
#listen [::]:80; 
{% endif %} 
{% if certificate -%} 
#listen 443 ssl{% if http2_support %} http2{% endif %}; 
{% if ipv6 -%} 
#listen [::]:443 ssl{% if http2_support %} http2{% endif %}; 
{% else -%} 
#listen [::]:443; 
{% endif %} 
{% endif %} 
server_name {{ domain_names | join: " " }}; 

now in every new confing the default listen will be commented out, and you have to manually add it in the advanced config.

listen 80; 
listen 443 ssl http2;

or in you case:

listen 8443 ssl;

this makes the http2 and SSL switches in the UI kinda useless and is more Work but its Persistent.

zer0brain avatar Aug 29 '23 15:08 zer0brain

I'm trying to make the custom listening port work with WebSockets but the default toggle in the UI does not work. Any idea what I need to add to the advanced configuration?

davmc123 avatar Feb 19 '24 20:02 davmc123

Alright, I don't want to revive a dead post, but I tried this and it worked. Sort of, it forwarded it to my port, but it's not ssl secured?

naterfute avatar Jun 08 '24 07:06 naterfute