Docker中的基本反向代理:禁止(无权限)

时间:2017-08-21 14:52:22

标签: php apache docker nginx proxy

我在8080上启动jwilder nginx代理

docker run -d -p 8080:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy

我在没有映射端口的情况下运行标准php:apache容器(因此80在容器网络上公开)。 我使用env var连接代理:

docker run -d -e VIRTUAL_HOST=test.example.com php:apache

在我的localhost上我已经在/ etc / hosts中添加了这个:

IP test.example.com

现在我在我的计算机上访问text.example.com:8080,所以我尝试连接反向代理(8080),它将把我路由到容器端口80上的php-apache。

但是我收到了这个错误:

错误:

Forbidden

You don't have permission to access / on this server.
Apache/2.4.10 (Debian) Server at test.example.com Port 8080

我错过了什么?我是否在某处更改了apache配置? (它现在都是默认的)。它似乎经历了nginx,因为我看到了apache错误,所以我想我需要告诉内部的apache(php apache):允许这个'路由')?

1 个答案:

答案 0 :(得分:1)

您的标题似乎具有误导性。根据您的描述,您已经设置了正常运行的反向代理,并且您使用反向代理连接的目标已损坏。如果您查看docker hub page on the php:apache image,您将找到有关如何将PHP代码加载到图像中并使其正常工作的多个示例。 E.g:

article