skip to Main Content

I would like to setup the local pgadmin in server mode behind the reverse proxy. The reverse proxy and the pgadmin could be on the same machine. I tried to set up but it always fails.
Here is mypgadmin conf:

Listen 8080
<VirtualHost *:8080>
  SSLEngine on
  SSLCertificateFile /etc/pki/tls/certs/pgadmin.crt
  SSLCertificateKeyFile /etc/pki/tls/private/pgadmin.key

  LoadModule wsgi_module modules/mod_wsgi.so
  LoadModule ssl_module modules/mod_ssl.so
  WSGIDaemonProcess pgadmin processes=1 threads=25
  WSGIScriptAlias /pgadmin /usr/lib/python2.7/site-packages/pgadmin4-web/pgAdmin4.wsgi

  <Directory /usr/lib/python2.7/site-packages/pgadmin4-web/>
          WSGIProcessGroup pgadmin
          WSGIApplicationGroup %{GLOBAL}
          <IfModule mod_authz_core.c>
                  # Apache 2.4
                  Require all granted
          </IfModule>
          <IfModule !mod_authz_core.c>
                  # Apache 2.2
                  Order Deny,Allow
                  Deny from All
                  Allow from 127.0.0.1
                  Allow from ::1
          </IfModule>
  </Directory>
</VirtualHost>

and my reverse proxy conf

Listen 443

<VirtualHost *:443>

        SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/localhost.crt
    SSLCertificateKeyFile /etc/pki/tls/private/localhost.key


    ErrorLog /var/log/httpd/reverse_proxy_error.log
    CustomLog /var/log/httpd/reverse_proxy_access.log combined

    SSLProxyEngine on
    SSLProxyVerify require
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCACertificateFile "/etc/pki/tls/certs/ca-bundle.crt"

    ProxyPreserveHost On    

    ProxyPass   /   https://localhost:8080/pgadmin
    ProxyPassReverse    /   https://localhost:8080/pgadmin   

</VirtualHost>

The httpd start but when I want to test it with

wget --no-check-certificate https://localhost/

it give me error 400

but the

wget --no-check-certificate https://localhost:8080/pgadmin

is working. Where is the problem in my config?

3

Answers


  1. Have you tried with latest version, I think it is fixed this commit Ref: LINK

    Online Docs: https://www.pgadmin.org/docs/pgadmin4/dev/server_deployment.html

    Login or Signup to reply.
  2. This config works,
    use 0.0.0.0 for pgadmin docker, else use your ip

    change port 5050 with your pgadmin port

    <VirtualHost *:80>
     ServerName pgadmin.yourdomain.com
     RedirectMatch permanent ^/pgadmin4$ /pgadmin4/
     ProxyPreserveHost On
     ProxyPass / http://0.0.0.0:5050/
     ProxyPassReverse / http://0.0.0.0:5050/
     Header edit Location ^/ /pgadmin4/
     Header always set X-Script-Name /pgadmin4
    </VirtualHost>
    

    Cofigure with SSL, replace yourdomain.com with valid SSL for your domain

    <VirtualHost *:80>
        ServerName pgadmin.yourdomain.com
        RedirectMatch permanent ^/(.*)$ https://pgadmin.yourdomain.com/$1
    </VirtualHost>
    
    
    <VirtualHost *:443>
     ServerName pgadmin.yourdomain.com
    
     SSLEngine on
     SSLCertificateFile /etc/letsencrypt/live/yourdomain.com/fullchain.pem
     SSLCertificateKeyFile /etc/letsencrypt/live/yourdomain.com/privkey.pem
    
     RedirectMatch permanent ^/pgadmin4$ /pgadmin4/
     ProxyPreserveHost On
     ProxyPass / http://0.0.0.0:5050/
     ProxyPassReverse / http://0.0.0.0:5050/
     Header edit Location ^/ /pgadmin4/
     Header always set X-Script-Name /pgadmin4
    
    </VirtualHost>
    
    Login or Signup to reply.
  3. this work for me. I make pgadmin proxy to sub directory (https://localhost/pgadmin)

    <VirtualHost *:80>
        ServerName localhost
    
        DocumentRoot "/var/www"
        
        <Directory "/var/www">
            AllowOverride all
        </Directory
    
        ProxyPass /ws/ ws://0.0.0.0:8888/
    
        ProxyPass /phpmyadmin/ http://phpmyadmin/
    
        <Location /pgadmin/>
            ProxyPass http://pgadmin:5050/
            ProxyPassReverse http://pgadmin:5050/
    
            RequestHeader set X-Script-Name /pgadmin
            RequestHeader set Host $http_host
        </Location>
    </VirtualHost>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search