我使用docker-compose文件为postgresql和phppgadmin如下:
我
postgresql:
image: "postgres:13-alpine"
restart: always
environment:
POSTGRES_DB: project
POSTGRES_USER: django
POSTGRES_PASSWORD: django
PGDATA: "/var/lib/postgresql/data/pgdata"
networks:
- postgresql_network
phppgadmin:
image: "bitnami/phppgadmin:7.13.0"
environment:
DATABASE_HOST: "postgresql"
DATABASE_SSL_MODE: "disable"
depends_on:
- postgresql
networks:
- nginx_network
- postgresql_network
ports:
- 80:8080
如果我在本地主机上运行这个,我可以连接到站点。这是http://localhost
,一切正常
但是如果我在服务器上说一些ip地址:xx.xx.xx.xx并尝试连接http://xx.xx.xx.xx
然后显示
Bad Request
Your browser sent a request that this server could not understand.
Additionally, a 400 Bad Request error was encountered while trying to use an ErrorDocument to handle the request.
我发现vhost为:
$ cat /opt/bitnami/apache/conf/bitnami/bitnami.conf
# Default Virtual Host configuration.
# Let Apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto https HTTPS=on
<VirtualHost _default_:8080>
DocumentRoot "/opt/bitnami/apache/htdocs"
<Directory "/opt/bitnami/apache/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
# Error Documents
ErrorDocument 503 /503.html
</VirtualHost>
Include "/opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf"
和phppgadmin-vhost.conf
$ cat /opt/bitnami/apache/conf/vhosts/phppgadmin-vhost.conf
<VirtualHost 127.0.0.1:8080 _default_:8080>
ServerAlias *
DocumentRoot /opt/bitnami/phppgadmin
<Directory "/opt/bitnami/phppgadmin">
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
我发现日志如下:
$ ls -al /opt/bitnami/apache/logs
total 16
drwxrwxr-x 1 root root 4096 Aug 16 01:25 .
drwxrwxr-x 1 root root 4096 Aug 16 01:24 ..
lrwxrwxrwx 1 root root 11 Aug 16 01:25 access_log -> /dev/stdout
lrwxrwxrwx 1 root root 11 Aug 16 01:25 error_log -> /dev/stderr
drwxrwxr-x 1 root root 4096 Jan 1 1970 pagespeed_log
我在error_log
中没有看到任何错误在我的docker组成我看到
phppgadmin_1 | 172.29.0.4 - - [17/Aug/2021:04:23:44 +0000] "GET / HTTP/1.0" 400 347
Bitnami Developer here
您是否正在访问端口80或者端口8080? 请注意,容器正在监听端口8080你可能没有在远程服务器上做端口映射,就像你在本地使用Docker Compose那样。
是否可以添加环境变量PHPPGADMIN_ALLOW_REMOTE_CONNECTIONS=yes到"phppgadmin";容器在您的docker-compose.yaml?
最后,也请分享vhost/opt/bitnami/apache/conf/vhosts/phppgadmin-vhost.conf的内容如果你还在挣扎