[GH-ISSUE #1563] Forward to a subfolder in the proxy host settings instead of just a port #1181

Closed
opened 2026-02-26 06:36:07 +03:00 by kerem · 10 comments
Owner

Originally created by @denppa on GitHub (Nov 4, 2021).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1563

Is your feature request related to a problem? Please describe.
Some apps like guacamole by apache resides in example.com/guacamole
And in the bare metal nginx server I had before using this I did set it to forward to 127.0.0.1:8080/guacamole instead.

Describe the solution you'd like
Maybe a option to enter in a custom forwarding address without the http/https, ip, and port selections?

Describe alternatives you've considered
Editing the config manually, it does not stay there once the proxy host is edited from the GUI end. (Unless I am mistaken.)

Originally created by @denppa on GitHub (Nov 4, 2021). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1563 <!-- 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.** Some apps like guacamole by apache resides in example.com/guacamole And in the bare metal nginx server I had before using this I did set it to forward to `127.0.0.1:8080/guacamole` instead. **Describe the solution you'd like** Maybe a option to enter in a custom forwarding address without the http/https, ip, and port selections? **Describe alternatives you've considered** Editing the config manually, it does not stay there once the proxy host is edited from the GUI end. (Unless I am mistaken.)
kerem 2026-02-26 06:36:07 +03:00
Author
Owner

@chaptergy commented on GitHub (Nov 4, 2021):

I don't really understand, why can't you use a custom location? Set the location / with scheme http, forward host 127.0.0.1/guacamole and port 8080?

<!-- gh-comment-id:961273444 --> @chaptergy commented on GitHub (Nov 4, 2021): I don't really understand, why can't you use a custom location? Set the location `/` with scheme `http`, forward host `127.0.0.1/guacamole` and port `8080`?
Author
Owner

@denppa commented on GitHub (Nov 5, 2021):

I don't really understand, why can't you use a custom location? Set the location / with scheme http, forward host 127.0.0.1/guacamole and port 8080?

I did set a custom location / with forwarding to IP/guacamole, but it did not work. I was simply directed to :8080 in which tomcat was running on, no guacamole until I typed in /guacamole

Back in bare metal nginx I just used this, proxy forward http:IP:8080/guacamole with server name http://guac.example.com

And upon visiting it without a sub directory would get me to /guacamole, what do you think I could do on the GUI end to make this happen except editing the file it self?

<!-- gh-comment-id:961881744 --> @denppa commented on GitHub (Nov 5, 2021): > I don't really understand, why can't you use a custom location? Set the location `/` with scheme `http`, forward host `127.0.0.1/guacamole` and port `8080`? I did set a custom location / with forwarding to IP/guacamole, but it did not work. I was simply directed to :8080 in which tomcat was running on, no guacamole until I typed in /guacamole Back in bare metal nginx I just used this, proxy forward http:IP:8080/guacamole with server name http://guac.example.com And upon visiting it without a sub directory would get me to /guacamole, what do you think I could do on the GUI end to make this happen except editing the file it self?
Author
Owner

@chaptergy commented on GitHub (Nov 5, 2021):

Could you please provide the code snippet you used before on the baremetal nginx?

<!-- gh-comment-id:961886644 --> @chaptergy commented on GitHub (Nov 5, 2021): Could you please provide the code snippet you used before on the baremetal nginx?
Author
Owner

@denppa commented on GitHub (Nov 5, 2021):

Could you please provide the code snippet you used before on the baremetal nginx?

Of course, this is it:

server {
    listen 80;
    listen [::]:80;
    server_name guac.example.com;

    return 301 https://$host$request_uri;
}

server {

    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name guac.example.com;

    include /etc/nginx/ssl.conf;

    location / {
    proxy_pass http://127.0.0.1:8080/guacamole/;
    proxy_buffering off;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    access_log off;
    }
}
<!-- gh-comment-id:961905625 --> @denppa commented on GitHub (Nov 5, 2021): > Could you please provide the code snippet you used before on the baremetal nginx? Of course, this is it: ``` server { listen 80; listen [::]:80; server_name guac.example.com; return 301 https://$host$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name guac.example.com; include /etc/nginx/ssl.conf; location / { proxy_pass http://127.0.0.1:8080/guacamole/; proxy_buffering off; proxy_http_version 1.1; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; access_log off; } } ```
Author
Owner

@chaptergy commented on GitHub (Nov 5, 2021):

That's pretty much what should be generated when adding the cusom location. It could be the missing trailing slash after 127.0.0.1/guacamole? Try it with another slash added at the end.

<!-- gh-comment-id:961912205 --> @chaptergy commented on GitHub (Nov 5, 2021): That's pretty much what should be generated when adding the cusom location. It could be the missing trailing slash after `127.0.0.1/guacamole`? Try it with another slash added at the end.
Author
Owner

@denppa commented on GitHub (Nov 6, 2021):

That's pretty much what should be generated when adding the cusom location. It could be the missing trailing slash after 127.0.0.1/guacamole? Try it with another slash added at the end.

I see what you mean, but instead now I am just redirected to a blank page. Without even the tomcat successful message.
https://i.imgur.com/RBTnRIU.png

npm generated conf:

  location / {
    set              $upstream http://172.17.0.1:8080/guacamole/$request_uri;
    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       $upstream;

This does not look right to me, why is there a trailing $variable?

<!-- gh-comment-id:962381182 --> @denppa commented on GitHub (Nov 6, 2021): > That's pretty much what should be generated when adding the cusom location. It could be the missing trailing slash after `127.0.0.1/guacamole`? Try it with another slash added at the end. I see what you mean, but instead now I am just redirected to a blank page. Without even the tomcat successful message. https://i.imgur.com/RBTnRIU.png npm generated conf: ``` location / { set $upstream http://172.17.0.1:8080/guacamole/$request_uri; 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 $upstream; ``` This does not look right to me, why is there a trailing $variable?
Author
Owner

@chaptergy commented on GitHub (Nov 6, 2021):

Are you talking about $request_uri? That's because when using a variable in proxy_pass nginx no longer automatically appends the path to the url, but expects the entire url. So if it was not there, requesting /foo or anything else would always be redirected to just http://172.17.0.1:8080/guacamole instead of http://172.17.0.1:8080/guacamole/foo.

Are you on v2.9.11?
It most likely has to do something with the $request_uri being basically empty, so just a slash. Please go ahead and manually edit the config inside the container and replace this line:

set              $upstream http://172.17.0.1:8080/guacamole$request_uri;

with these lines

set              $upstream {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }};
if ($request_uri != /){
  set            $upstream $upstream$request_uri;
}
<!-- gh-comment-id:962444888 --> @chaptergy commented on GitHub (Nov 6, 2021): Are you talking about `$request_uri`? That's because when using a variable in `proxy_pass` nginx no longer automatically appends the path to the url, but expects the entire url. So if it was not there, requesting `/foo` or anything else would always be redirected to just `http://172.17.0.1:8080/guacamole` instead of `http://172.17.0.1:8080/guacamole/foo`. Are you on v2.9.11? It most likely has to do something with the `$request_uri` being basically empty, so just a slash. Please go ahead and manually edit the config inside the container and replace this line: ```nginx set $upstream http://172.17.0.1:8080/guacamole$request_uri; ``` with these lines ```nginx set $upstream {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }}; if ($request_uri != /){ set $upstream $upstream$request_uri; } ```
Author
Owner

@denppa commented on GitHub (Nov 8, 2021):

Are you talking about $request_uri? That's because when using a variable in proxy_pass nginx no longer automatically appends the path to the url, but expects the entire url. So if it was not there, requesting /foo or anything else would always be redirected to just http://172.17.0.1:8080/guacamole instead of http://172.17.0.1:8080/guacamole/foo.

Are you on v2.9.11? It most likely has to do something with the $request_uri being basically empty, so just a slash. Please go ahead and manually edit the config inside the container and replace this line:

set              $upstream http://172.17.0.1:8080/guacamole$request_uri;

with these lines

set              $upstream {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }};
if ($request_uri != /){
  set            $upstream $upstream$request_uri;
}

Yes I am using the docker image version
2.9.11

Does that mean I should pull and update it so I don't have to manually edit?

<!-- gh-comment-id:962794010 --> @denppa commented on GitHub (Nov 8, 2021): > Are you talking about `$request_uri`? That's because when using a variable in `proxy_pass` nginx no longer automatically appends the path to the url, but expects the entire url. So if it was not there, requesting `/foo` or anything else would always be redirected to just `http://172.17.0.1:8080/guacamole` instead of `http://172.17.0.1:8080/guacamole/foo`. > > Are you on v2.9.11? It most likely has to do something with the `$request_uri` being basically empty, so just a slash. Please go ahead and manually edit the config inside the container and replace this line: > > ```nginx > set $upstream http://172.17.0.1:8080/guacamole$request_uri; > ``` > > with these lines > > ```nginx > set $upstream {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }}; > if ($request_uri != /){ > set $upstream $upstream$request_uri; > } > ``` Yes I am using the docker image version `2.9.11` Does that mean I should pull and update it so I don't have to manually edit?
Author
Owner

@denppa commented on GitHub (Nov 9, 2021):

Any ways, for whatever reason adding the custom location just does not work with guacamole client.
And after the update, I saw you used some fancy format for forwarding the proxy host, and I can no longer set the proxy pass as I used to.
I will just bookmark it with the sub directory instead.

<!-- gh-comment-id:964200079 --> @denppa commented on GitHub (Nov 9, 2021): Any ways, for whatever reason adding the custom location just does not work with guacamole client. And after the update, I saw you used some fancy format for forwarding the proxy host, and I can no longer set the proxy pass as I used to. I will just bookmark it with the sub directory instead.
Author
Owner

@tdp4 commented on GitHub (Dec 16, 2023):

I was able to do this in v2.10.4 with a custom location of / -> hostname/guacamole/ on port 8080

<!-- gh-comment-id:1858916366 --> @tdp4 commented on GitHub (Dec 16, 2023): I was able to do this in v2.10.4 with a custom location of `/` -> hostname/guacamole/ on port 8080
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#1181
No description provided.