nginx-proxy-manager: Custom Location fails on second, third,...

Great project, nice interface and function, thank you!

I have a single proxy host domain configured with two custom locations, aka /path(s). The first path works/is redirected as expected. The second, third, … return a 404. I’ve included my docker-compose.yml, ./data/nginx/proxy_host/1.conf snippet, and screenshots.

I’m not sure what it is I might be missing in the configuration or if indeed it’s a bug. I’m a little unclear on the Use 1.1.1.1/path for sub-folder forwarding statement under the /path field. Obviously your wouldn’t use 1.1.1.1, or other DNS. I tried using the subdomain.domain.com but that failed as I would have expected since it would create a loop. I’m also a little confused on the destination port setting of the proxy host since I’m redirecting using a custom location/path. No port setting I’ve tried resolves the issue and no port is not an option as it’s required.

Thank you

Checklist

  • Have you pulled and found the error with jc21/nginx-proxy-manager:latest docker image? YES
version: "3"
services:
  app:
    image: jc21/nginx-proxy-manager:latest
    restart: always
    ports:
      # Public HTTP Port:
      - '80:80'
      # Public HTTPS Port:
      - '443:443'
      # Admin Web Port:
      - '81:81'
    environment:
      # Uncomment this if IPv6 is not enabled on your host
      DISABLE_IPV6: 'true'
    volumes:
      # Make sure this config.json file exists as per instructions above:
      - ${USERDIR}/nginx_proxy_manager/config.json:/app/config/production.json
      - ${USERDIR}/nginx_proxy_manager/data:/data
      - ${USERDIR}/nginx_proxy_manager/letsencrypt:/etc/letsencrypt
    depends_on:
      - db
  db:
    image: mariadb:latest
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: <obfuscated>
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'ngx_user'
      MYSQL_PASSWORD: <obfuscated>
    volumes:
      - ${USERDIR}/nginx_proxy_manager/data/mysql:/var/lib/mysql
  • Are you sure you’re not using someone else’s docker image? YES

  • If having problems with Lets Encrypt, have you made absolutely sure your site is accessible from outside of your network?

Describe the bug The first custom location works as expected. The second, third, … fail with a 404

  • What version of Nginx Proxy Manager is reported on the login page? 2.7.1

To Reproduce Steps to reproduce the behavior:

  1. Enter a custom location for a domain
  2. Navigate to the “custom location” aka /path in my browser’s address bar
  3. See the 404 error

Expected behavior

  1. After creating the Custom Location navigating to custom location, aka /path and have page displayed

Screenshots image

image image image image image image image image

snippet from ./data/nginx/proxy_host/1.conf

#...
  location /smokeping {
    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://10.10.0.173:9001;

  }

  location /dockerui {
    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://10.10.0.173:9000;
    
  }
#...

Operating System Ubuntu 20.04.1 Docker version 19.03.13, build 4484c46d9d docker-compose version 1.27.4 HP Elite 8300 i5-3470S, 16GB Ram, 1TB SSD

./data/logs/proxy_host-1.log

[05/Dec/2020:20:17:33 +0000] - 404 404 - GET https <obfuscated>.com "/dockerui" [Client 10.10.0.1] [Length 19] [Gzip -] [Sent-to 10.10.0.173] "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36" "-"

No relative info from

data/logs/error.log
data/logs/default_host.log
data/logs/default.log

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17

Most upvoted comments

@federicoalvarez-github What works is

Edit proxy host -> Advanced -> Custom Nginx Configuration

location /dockerui/ {
    rewrite /dockerui/(.*) /$1  break;
    proxy_pass  http://10.10.0.173:9000;
}

location / {
    # Proxy!
    include conf.d/include/proxy.conf;
}

So the final answer is NPM UI cannot create these rules it seems, so custom locations cannot apply to ports without custom rules for nginx. Isnt the whole point of this app to create rules for you though?

@federicoalvarez-github What works is

Edit proxy host -> Advanced -> Custom Nginx Configuration

location /dockerui/ {
    rewrite /dockerui/(.*) /$1  break;
    proxy_pass  http://10.10.0.173:9000;
}

location / {
    # Proxy!
    include conf.d/include/proxy.conf;
}

!! Thank you after many hours of searching/ trial and error this worked for me. Hopefully I can use this for other services where I cant modify the url base (maybe home-assistant)

My domain is example.com and i access my app through example.com/app1 and whenever i click on a link through my app it goes to the link example.com/login.html instead of example.com/app1/login.html. Config :

location /app1/ { rewrite /app1/(.*) /$1 break; proxy_pass http://192.168.x.x:80; }

If there is anyone as noob as me: you are going to make changes inside ngix proxy manager website go to the proxy hosts page and click on the 3 dot thing on the site of your host, there are 5 tabs, go to the advanced tab and paste what the masters gave us above:

location /portainer/ { rewrite /portainer/(.*) /$1 break; proxy_pass https://192.168.1.6:9443; }

change the names “portainer” to the app you want to add and the ip/port to the one assigned to the app you want to use

save and be happy.

REMEMBER, DON’T BE DUMB LIKE ME AND DON’T ADD THE SAME THING ON CUSTOM LOCATIONS TAB… KEEP IT EMPTY

adding the above mentioned code to the advanced tab added this towards the top of my config file above all my other custom locations

location /portainer/ { rewrite /portainer/(.*) /$1 break; proxy_pass https://192.168.1.6:9443; }

From custom locations ui set the path as /portainer/ and fill in the rest like you normally would. then click the gear icon and in the custom section add rewrite /portainer/(.*) /$1 break;.

that might do the trick without needing to use the advanced tab and should add the same thing to your config as listed above but I have not tested this yet.

(I did not use the location / { # Proxy! include conf.d/include/proxy.conf line as I already had that location block in my config file.)