0

I have an nginx and a pgadmin Docker container connected to each other. Only nginx container is exposed to the outside. How can I map pgadmin to a sub URI?

If the host is example.com, I want the pgadmin to be reachable at example.com/pgadmin/. So far, I have this in my nginx.conf file:

location ^~ /pgadmin/ {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://pgadmin:80/;
}

A request to example.com/pgadmin/ goes through to pgadmin but when pgadmin redirects to the login page, it redirects to example.com/login?next=%2F, not to example.com/pgadmin/login?next=%2F.

How can I make pgadmin to work at example.com/pgadmin?

yam
  • 1,383
  • 3
  • 15
  • 34

1 Answers1

0

I understand that you want to map http://pgadmin:80/ to http://example.com/pgadmin/. Add the below entry in your hosts file to map pgadmin to example.com

pgadmin    example.com

Now to map the :80 to /pgadmin, add the following in your nginx.conf :

location /pgadmin {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://pgadmin:80/;
}
Jahnavi Paliwal
  • 1,721
  • 1
  • 12
  • 20