[GH-ISSUE #1477] After port mapping is done through the firewall the access URL will hide the port number #1137

Closed
opened 2026-02-26 06:35:55 +03:00 by kerem · 1 comment
Owner

Originally created by @wsczx on GitHub (Oct 11, 2021).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1477

After the internal network uses npm to do port mapping through the firewall, the access url will hide the port number, resulting in normal access. After testing, you need to modify the /etc/nginx/conf.d/include/proxy.conf file in the container!

Original configuration file:

add_header X-Served-By $host;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass $forward_scheme://$server:$port;

Need to be modified to:

add_header X-Served-By $host;
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 $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass $forward_scheme://$server:$port;

But every time you update the version, you need to enter the container to modify it. Is there a way to directly make the initial default value of proxy_set_header Host $http_host; instead of proxy_set_header Host $host; without recompiling the container?

Originally created by @wsczx on GitHub (Oct 11, 2021). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1477 > After the internal network uses npm to do port mapping through the firewall, the access url will hide the port number, resulting in normal access. After testing, you need to modify the` /etc/nginx/conf.d/include/proxy.conf` file in the container! **Original configuration file:** ```nginx add_header X-Served-By $host; proxy_set_header Host $host; proxy_set_header X-Forwarded-Scheme $scheme; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Real-IP $remote_addr; proxy_pass $forward_scheme://$server:$port; ``` **Need to be modified to:** ```nginx add_header X-Served-By $host; 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 $remote_addr; proxy_set_header X-Real-IP $remote_addr; proxy_pass $forward_scheme://$server:$port; ``` But every time you update the version, you need to enter the container to modify it. Is there a way to directly make the initial default value of `proxy_set_header Host $http_host;` instead of `proxy_set_header Host $host;` without recompiling the container?
kerem 2026-02-26 06:35:55 +03:00
Author
Owner

@chaptergy commented on GitHub (Oct 11, 2021):

I don't understand why you have to change $host to $http_host, is this something which would have to be changed in general or just for your specific configuration?

But you can mount a custom your own /etc/nginx/conf.d/include/proxy.conf into the container which will then overwrite the existing file inside the container.

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    ...
    volumes:
      ...
      - /path/to/custom/proxy.conf:/etc/nginx/conf.d/include/proxy.conf
...

Though the file has not changed in almost a year, please note that you will also overwrite any updates to this file, so you should have an eye on whether new versions change anything in this file. At least you should keep in mind you overwrite this file if you encounter any problems after updating.

<!-- gh-comment-id:939943722 --> @chaptergy commented on GitHub (Oct 11, 2021): I don't understand why you have to change `$host` to `$http_host`, is this something which would have to be changed in general or just for your specific configuration? But you can mount a custom your own `/etc/nginx/conf.d/include/proxy.conf` into the container which will then overwrite the existing file inside the container. ```yml version: '3' services: app: image: 'jc21/nginx-proxy-manager:latest' ... volumes: ... - /path/to/custom/proxy.conf:/etc/nginx/conf.d/include/proxy.conf ... ``` Though the file has not changed in almost a year, please note that you will also overwrite any updates to this file, so you should have an eye on whether new versions change anything in this file. At least you should keep in mind you overwrite this file if you encounter any problems after updating.
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#1137
No description provided.