Hosting pgAdmin4 behind nginx and at /pgdmin, for mortals

From: Shaheed Haque <srhaque(at)theiet(dot)org>
To: pgadmin-support(at)postgresql(dot)org
Subject: Hosting pgAdmin4 behind nginx and at /pgdmin, for mortals
Date: 2019-02-25 23:25:04
Message-ID: CAHAc2jfjd7TxAyOAxzHLVuTm_K-s9WWNPZSrehSFaQB77BQYuw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

Hi,

I'm a relative noob when it comes to the world of nginx, wsgi and so forth,
but I do have several other things working (a Django app under gunicorn and
the RabbitMQ web UI directly behind nginx). However, I'm rather stuck
getting pgAdmin4 to run at http://mydomain.com:80/pgadmin behind nginx. Is
there a simple, up-to-date example of how to do this (I'm running the
latest, v4.2, of pgAdmin4)?

I'm aware of threads such as
https://www.postgresql.org/message-id/2197768425D7F5479A0FFB3FEC212F7FF602B871%40aesmail.surcouf.local,
and several others but not been able to come up with a clear approach:

One of the several variables I'm struggling to understand is the choice of
whether to run pgAdmin4.py on port 5050 directly behind nginx, or as a WSGI
app under gunicorn. I assume the latter should be easier to set up, but
I've tried both (modelled on what I have working, and various references).
One combination I tried was:

- Creating a softlink from pgadmin4.py to pgAdmin4.wsgi
- Using gunicorn to run the pgadmin4.py to a unix domain socket like this:

$ /usr/local/bin/gunicorn -w 1 --bind unix:/home/ubuntu/pgadmin.sock
pgadmin4:application

- Serving behind nginx like this:

location /pgadmin {
rewrite ^/pgadmin/(.*) /$1 break;
include proxy_params;
proxy_pass http://unix:/home/ubuntu/pgadmin.sock;
}

But all I get is a stubborn 404. Any pointers welcome...

Thanks, Shaheed

P.S. I considered just making pgAdmin4.py listen on 0.0.0.0:5050, but I do
need to get everything behind HTTPS sooner rather than later.

Responses

Browse pgadmin-support by date

  From Date Subject
Next Message Raphaël Martin 2019-02-27 12:41:59 Bug report : update / delete impossible when primary key contain %
Previous Message Dave Page 2019-02-22 08:52:03 Re: [pgadmin4] Make.bat with python3.6