[GH-ISSUE #927] convert docker name to variable #784

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

Originally created by @GurjinderSingh on GitHub (Mar 5, 2021).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/927

Is your feature request related to a problem? Please describe.

current natural version when create new custom location.

  location /ubuntuvnc {
    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_pass       http://ubuntuvnc:80/;
  }

try to change in custom location to variable and add extra rule set

image

output

  location /ubuntuvnc {
    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_pass       http://$ubuntuvnc:3000;
    set $ubuntuvnc ubuntuvnc;

  }

Problem : if we set variable below proxy pass will not work. please let me know if I made mistake

working best configuration location block

  location /ubuntuvnc {
    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;

    set $ubuntuvnc ubuntuvnc;
    proxy_pass       http://$ubuntuvnc:80;
  }

for ubuntu vnc need to add websocket config : https://github.com/jc21/nginx-proxy-manager/issues/926

Describe the solution you'd like

Allow option to make host variable or do it by default. I believe most of NPM user use it with docker hosts so any docker container can crash or admin can delete will crash NPM.

Why did I go crazy for it 0_0 ??

I am trying to setup NPM with three DO VPS docker swarm.

  1. file-system is shared with gluster.
  2. MySQL cluster available every host.
  3. All container can run on every host.
  4. My stack contains Wordpress, mail server and some php scripts.

problem arose when my one vps with NPM and other container crashed while testing. NPM started on another server as expected but nginx kept crashing due to one container failed to start.

Describe alternatives you've considered

I have to create every custom location like this. not tested but maybe I have to create main hosts too

image

Additional context

https://github.com/jc21/nginx-proxy-manager/issues/926

Originally created by @GurjinderSingh on GitHub (Mar 5, 2021). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/927 **Is your feature request related to a problem? Please describe.** current natural version when create new custom location. ``` location /ubuntuvnc { 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_pass http://ubuntuvnc:80/; } ``` try to change in custom location to variable and add extra rule **set** ![image](https://user-images.githubusercontent.com/3470709/110096452-e9a7e800-7d6b-11eb-9e7f-59c6f69143b7.png) output ``` location /ubuntuvnc { 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_pass http://$ubuntuvnc:3000; set $ubuntuvnc ubuntuvnc; } ``` **Problem** : if we set variable below proxy pass will not work. please let me know if I made mistake working best configuration location block ``` location /ubuntuvnc { 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; set $ubuntuvnc ubuntuvnc; proxy_pass http://$ubuntuvnc:80; } ``` **for ubuntu vnc need to add websocket config** : https://github.com/jc21/nginx-proxy-manager/issues/926 **Describe the solution you'd like** Allow option to make host variable or do it by default. I believe most of NPM user use it with docker hosts so any docker container can crash or admin can delete will crash NPM. **Why did I go crazy for it 0_0 ??** I am trying to setup NPM with three DO VPS docker swarm. 1. file-system is shared with gluster. 2. MySQL cluster available every host. 3. All container can run on every host. 4. My stack contains Wordpress, mail server and some php scripts. problem arose when my one vps with NPM and other container crashed while testing. NPM started on another server as expected but nginx kept crashing due to one container failed to start. **Describe alternatives you've considered** I have to create every custom location like this. not tested but maybe I have to create main hosts too ![image](https://user-images.githubusercontent.com/3470709/110099708-9f286a80-7d6f-11eb-853c-0f8b6517de84.png) **Additional context** https://github.com/jc21/nginx-proxy-manager/issues/926
kerem 2026-02-26 06:34:25 +03:00
Author
Owner

@GurjinderSingh commented on GitHub (Mar 14, 2021):

found a way around for my dynamic container problem. when testing with multiple service add custom host on some services failed to work properly. plus for some container I love to use for testing and kill them when not needed EX, ubuntu vnc, firefox phpmyadmin, theia-php and some others.

Target : dynamic containers aka only boot up container when required served by NPM.

Problem : NPM nginx restart will never boot until all proxy host/container available

solution add each host dynamically with $var to proxy host. scroll up ^-^

solution for devolvement use dynamic subdomain with regex provide container name and port in subdomain

HowTO

step 1

create test.youdomain.com with SSL *.youdomain.com

don't forget to enable options required such as: web-sockets, password protection, block common exploits or force ssl.

step 2

locate conf file for domain test.yourdomain.com in directory DOCKER VOLUME nginx/proxy_host/ * conf
create file copy everthing >nginx/custom/http.conf

modify http.comf file required

#  set $server         "firefox";   # dynamically set  server_name
#  set $port           5800;
  ###      ubuntuvnc-8080.example.net
  server_name "~^(?<server>[^.]+)-(?<port>\d{1,4})\.example\.net";

Step 3

Final Step DON'T forget to test file and to reload NPM save any host from web interface.

File to add : nginx/custom/http.conf
read more https://github.com/jc21/nginx-proxy-manager/pull/948 -

github.com/jc21/nginx-proxy-manager@b7b808d98d/docker/rootfs/etc/nginx/nginx.conf (L73)

<!-- gh-comment-id:798892430 --> @GurjinderSingh commented on GitHub (Mar 14, 2021): found a way around for my dynamic container problem. when testing with multiple service add custom host on some services failed to work properly. plus for some container I love to use for testing and kill them when not needed EX, ubuntu vnc, firefox phpmyadmin, theia-php and some others. **Target** : dynamic containers aka only boot up container when required served by NPM. **Problem** : NPM nginx restart will never boot until all proxy host/container available **solution** add each host dynamically with $var to proxy host. scroll up ^-^ **solution for devolvement** use dynamic subdomain with regex provide container name and port in subdomain **HowTO** step 1 > create test.youdomain.com with SSL *.youdomain.com > > don't forget to enable options required such as: web-sockets, password protection, block common exploits or force ssl. step 2 > locate conf file for domain test.yourdomain.com in directory DOCKER VOLUME nginx/proxy_host/ * conf > create file copy everthing >nginx/custom/http.conf >modify http.comf file required ``` # set $server "firefox"; # dynamically set server_name # set $port 5800; ### ubuntuvnc-8080.example.net server_name "~^(?<server>[^.]+)-(?<port>\d{1,4})\.example\.net"; ``` Step 3 >Final Step DON'T forget to test file and to reload NPM save any host from web interface. **File to add** : nginx/custom/http.conf read more https://github.com/jc21/nginx-proxy-manager/pull/948 - https://github.com/jc21/nginx-proxy-manager/blob/b7b808d98d787b25548265055d9f8621d31b580e/docker/rootfs/etc/nginx/nginx.conf#L73
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#784
No description provided.