【发布时间】:2020-11-28 14:58:48
【问题描述】:
我正在尝试在 Docker 中使用 Docker Compose 在 Apache2 反向代理后面设置 BaGet,其中 Apache2 也在 Docker Compose 的 Docker 中运行。
我已经使用 Jenkins 和 Sonar 成功地完成了这项工作,但是使用 BaGet (http://localhost:8000/baget) 我得到“服务不可用”,即使它可以直接在自己的端口上使用,例如:http://本地主机:5555/。
我的 Docker Compose 文件如下所示:
version: "3"
services:
smtp:
container_name: smtp
image: namshi/smtp
jenkins:
container_name: jenkins
build: ./jenkins/
environment:
- JENKINS_OPTS="--prefix=/jenkins"
sonar:
container_name: sonar
image: sonarqube:latest
environment:
- SONAR_WEB_CONTEXT=/sonar
baget:
container_name: baget
image: loicsharma/baget:latest
ports:
- "5555:80"
environment:
- PathBase=/baget
apache:
container_name: apache
build: ./apache/
ports:
- "8000:80"
我的 Apache2 Docker 文件如下所示:
FROM debian:stretch
RUN apt-get update
RUN apt-get install -y apache2 && apt-get clean
RUN a2enmod proxy
RUN a2enmod proxy_http
RUN a2dissite 000-default.conf
COPY devenv.conf /etc/apache2/sites-available/devenv.conf
RUN a2ensite devenv
EXPOSE 80
CMD apachectl -D FOREGROUND
我的 Apache2 配置文件是这样的:
<VirtualHost *:80>
ServerAdmin ...
ServerName ...
ServerAlias devenv
ProxyRequests Off
AllowEncodedSlashes NoDecode
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost on
ProxyPass /jenkins http://jenkins:8080/jenkins nocanon
ProxyPassReverse /jenkins http://jenkins:8080/jenkins nocanon
ProxyPass /sonar http://sonar:9000/sonar nocanon
ProxyPassReverse /sonar http://sonar:9000/sonar nocanon
ProxyPass /baget http://baget:5555/baget nocanon
ProxyPassReverse /baget http://baget:5555/baget nocanon
</VirtualHost>
我尝试了各种不同的 ProxyPass URL 组合,我尝试使用 localhost 而不是内部 Docker Compose 服务名称,我尝试了不同的端口,我尝试在没有 PathBase 环境变量的情况下运行 BaGet,但没有任何效果!
我希望我的配置是显而易见的,而不是 BaGet 的奇怪行为。
【问题讨论】:
标签: apache docker docker-compose reverse-proxy