[GH-ISSUE #2969] Change NPM Listen port based on Proxy Host #2020

Open
opened 2026-02-26 07:33:43 +03:00 by kerem · 6 comments
Owner

Originally created by @CrazyVaclav on GitHub (May 31, 2023).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2969

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 ?

Originally created by @CrazyVaclav on GitHub (May 31, 2023). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2969 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](https://github.com/NginxProxyManager/nginx-proxy-manager/assets/75505454/9d4dcfce-1e02-40c6-864b-749c2a75f29d) 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 ?**
Author
Owner

@zer0brain commented on GitHub (Aug 29, 2023):

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.

<!-- gh-comment-id:1697383586 --> @zer0brain commented on GitHub (Aug 29, 2023): 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.
Author
Owner

@zer0brain commented on GitHub (Aug 29, 2023):

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.

<!-- gh-comment-id:1697732269 --> @zer0brain commented on GitHub (Aug 29, 2023): 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](url) 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.
Author
Owner

@davmc123 commented on GitHub (Feb 19, 2024):

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?

<!-- gh-comment-id:1953147996 --> @davmc123 commented on GitHub (Feb 19, 2024): 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?
Author
Owner

@naterfute commented on GitHub (Jun 8, 2024):

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?

<!-- gh-comment-id:2155851498 --> @naterfute commented on GitHub (Jun 8, 2024): 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?
Author
Owner

@github-actions[bot] commented on GitHub (Jan 10, 2025):

Issue is now considered stale. If you want to keep it open, please comment 👍

<!-- gh-comment-id:2581594980 --> @github-actions[bot] commented on GitHub (Jan 10, 2025): Issue is now considered stale. If you want to keep it open, please comment :+1:
Author
Owner

@wzwtt commented on GitHub (Nov 27, 2025):

My current solution is to replace all instances of 80/443 in the .conf files within the source code and then rebuild the image.

<!-- gh-comment-id:3586938296 --> @wzwtt commented on GitHub (Nov 27, 2025): My current solution is to replace all instances of 80/443 in the .conf files within the source code and then rebuild the image.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-proxy-manager-NginxProxyManager#2020
No description provided.