简体   繁体   English

使用 pgadmin 和 apache 进行反向代理

[英]Reverse Proxy with pgadmin and apache

I would like to setup the local pgadmin in server mode behind the reverse proxy.我想在反向代理后面以服务器模式设置本地 pgadmin。 The reverse proxy and the pgadmin could be on the same machine.反向代理和 pgadmin 可以在同一台机器上。 I tried to set up but it always fails.我尝试设置,但总是失败。 Here is mypgadmin conf:这是 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 httpd 开始,但是当我想用它进行测试时

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

it give me error 400它给了我错误 400

but the但是

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

is working.正在工作。 Where is the problem in my config?我的配置中的问题在哪里?

this work for me.这对我有用。 I make pgadmin proxy to sub directory (https://localhost/pgadmin)我使 pgadmin 代理到子目录(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>

Have you tried with latest version, I think it is fixed this commit Ref: LINK您是否尝试过最新版本,我认为它已修复此提交 Ref: LINK

Online Docs: https://www.pgadmin.org/docs/pgadmin4/dev/server_deployment.html在线文档: https : //www.pgadmin.org/docs/pgadmin4/dev/server_deployment.html

This config works, use 0.0.0.0 for pgadmin docker, else use your ip此配置有效,对 pgadmin docker 使用 0.0.0.0,否则使用您的 ip

change port 5050 with your pgadmin port使用 pgadmin 端口更改端口 5050

<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使用 SSL 配置,将 yourdomain.com 替换为您域的有效 SSL

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM