[GH-ISSUE #2516] Support other ports (non 80/443) configuration in headers via UI settings #1754

Open
opened 2026-02-26 07:32:20 +03:00 by kerem · 9 comments
Owner

Originally created by @GAS85 on GitHub (Jan 3, 2023).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2516

Is your feature request related to a problem? Please describe.
If my Application runs on different ports, e.g. 907X it will cause a bunch of trouble - port will not be forwarded to the service and at the end redirect happens on port 80 or 443 that are not configured by npm.
Docker-compose

version: "3.6"
services:
  nginx-proxy-manager:
    image: jc21/nginx-proxy-manager:latest
    container_name: npm
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - DB_SQLITE_FILE=/config/database.sqlite
      - DISABLE_IPV6=true
    ports:
      # Public HTTP Port. Port Forwarding on Router is ON.
      - 9070:80
      # Public HTTPS Port. Port Forwarding on Router is ON.
      - 9071:443
      # Admin Web Port. Port Forwarding on Router is OFF. Internal Home Network Access only - 192.168.89.254:81.
      - 9072:81
    volumes:
      - ${WORKINGDIR}/docker/npm/config:/config
      - ${WORKINGDIR}/docker/npm/letsencrypt:/etc/letsencrypt
      - ${WORKINGDIR}/docker/npm/data:/data

изображение

On a 1st line Service was found and it tells us to follow url http://jackett.fritz.box:9070/UI/Dashboard.
On a 2nd line Service would like to authorize user, but do not know port, so it skip it in a answer and ended up with wrong URL (no port) http://jackett.fritz.box/UI/Login?ReturnUrl=/UI/Dashboard and 404.

Describe the solution you'd like
Configure port in a proxy_set_header Host $host:PORT; will solve this issue.

изображение

Unlike current solution it is only proxy_set_header Host $host;. Add Possibility to enable and add custom port to the header Host.

Describe alternatives you've considered
I tried to use "Custom Location" and set it to the root so I can add proxy_set_header Host $host:PORT; but this will cause this entry twice: without port and at the end with port that cause an error.

Alternative 2 is to mount proxy.conf to the host machine:

    volumes:
      - ${WORKINGDIR}/docker/npm/data/nginx/include/proxy.conf:/etc/nginx/conf.d/include/proxy.conf

and update it:

add_header       X-Served-By $host;
#proxy_set_header Host $host:9070;
# Forward host and port
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto  $scheme;
proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP          $remote_addr;
proxy_pass       $forward_scheme://$server:$port$request_uri;

Additional context
There is no need to modify listen 80; part of the configuration and bind nginx to some other ports, it shall remains untouched. But underlining services need to know the Port.

Originally created by @GAS85 on GitHub (Jan 3, 2023). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2516 <!-- Are you in the right place? - If you are looking for support on how to get your upstream server forwarding, please consider asking the community on Reddit. - If you are writing code changes to contribute and need to ask about the internals of the software, Gitter is the best place to ask. - If you think you found a bug with NPM (not Nginx, or your upstream server or MySql) then you are in the *right place.* --> **Is your feature request related to a problem? Please describe.** If my Application runs on different ports, e.g. `907X` it will cause a bunch of trouble - port will not be forwarded to the service and at the end redirect happens on port `80` or `443` that are not configured by npm. Docker-compose ```yaml version: "3.6" services: nginx-proxy-manager: image: jc21/nginx-proxy-manager:latest container_name: npm environment: - PUID=${PUID} - PGID=${PGID} - TZ=${TZ} - DB_SQLITE_FILE=/config/database.sqlite - DISABLE_IPV6=true ports: # Public HTTP Port. Port Forwarding on Router is ON. - 9070:80 # Public HTTPS Port. Port Forwarding on Router is ON. - 9071:443 # Admin Web Port. Port Forwarding on Router is OFF. Internal Home Network Access only - 192.168.89.254:81. - 9072:81 volumes: - ${WORKINGDIR}/docker/npm/config:/config - ${WORKINGDIR}/docker/npm/letsencrypt:/etc/letsencrypt - ${WORKINGDIR}/docker/npm/data:/data ``` ![изображение](https://user-images.githubusercontent.com/6813635/210354844-69443697-f9e7-459b-b688-ceb9cb91d89f.png) On a 1st line Service was found and it tells us to follow url `http://jackett.fritz.box:9070/UI/Dashboard`. On a 2nd line Service would like to authorize user, but do not know port, so it skip it in a answer and ended up with wrong URL (no port) `http://jackett.fritz.box/UI/Login?ReturnUrl=/UI/Dashboard` and 404. **Describe the solution you'd like** Configure port in a `proxy_set_header Host $host:PORT;` will solve this issue. ![изображение](https://user-images.githubusercontent.com/6813635/210356619-0e2202f3-45d5-42fb-980b-6fe5127a99e8.png) Unlike current solution it is only `proxy_set_header Host $host;`. Add Possibility to enable and add custom port to the header Host. **Describe alternatives you've considered** I tried to use "Custom Location" and set it to the root so I can add `proxy_set_header Host $host:PORT;` but this will cause this entry twice: without port and at the end with port that cause an error. Alternative 2 is to mount `proxy.conf` to the host machine: ```yaml volumes: - ${WORKINGDIR}/docker/npm/data/nginx/include/proxy.conf:/etc/nginx/conf.d/include/proxy.conf ``` and update it: ```nginx add_header X-Served-By $host; #proxy_set_header Host $host:9070; # Forward host and port proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_pass $forward_scheme://$server:$port$request_uri; ``` **Additional context** There is no need to modify `listen 80;` part of the configuration and bind nginx to some other ports, it shall remains untouched. But underlining services need to know the Port.
Author
Owner

@lerra commented on GitHub (Feb 12, 2023):

I have the similar need, to be able to set a custom listening port for a specific domain/vhost/proxy host

<!-- gh-comment-id:1426999956 --> @lerra commented on GitHub (Feb 12, 2023): I have the similar need, to be able to set a custom listening port for a specific domain/vhost/proxy host
Author
Owner

@etonline commented on GitHub (May 31, 2023):

Same here, adding proxy_set_header Host $host in the custom setting of the "/" location will cause entry duplicate in the config file 😢

<!-- gh-comment-id:1570206269 --> @etonline commented on GitHub (May 31, 2023): Same here, adding` proxy_set_header Host $host` in the custom setting of the "/" location will cause entry duplicate in the config file 😢
Author
Owner

@YUJX19 commented on GitHub (Oct 29, 2023):

The same issue

<!-- gh-comment-id:1784004423 --> @YUJX19 commented on GitHub (Oct 29, 2023): The same issue
Author
Owner

@github-actions[bot] commented on GitHub (Jun 12, 2024):

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

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

@GAS85 commented on GitHub (Jun 12, 2024):

👍

<!-- gh-comment-id:2162531139 --> @GAS85 commented on GitHub (Jun 12, 2024): 👍
Author
Owner

@github-actions[bot] commented on GitHub (Mar 17, 2025):

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

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

@GAS85 commented on GitHub (Mar 17, 2025):

👍

<!-- gh-comment-id:2728918202 --> @GAS85 commented on GitHub (Mar 17, 2025): 👍
Author
Owner

@github-actions[bot] commented on GitHub (Dec 28, 2025):

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

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

@lerra commented on GitHub (Dec 28, 2025):

I would love to see this feature

<!-- gh-comment-id:3694408231 --> @lerra commented on GitHub (Dec 28, 2025): I would love to see this feature
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#1754
No description provided.