虚拟主机配置为Apache2 Web服务器上的反向代理

时间:2019-10-28 08:48:09

标签: apache reverse-proxy virtualhost

我在linux ubuntu 16.04计算机上的端口4567上作为docker容器运行了一项服务。 apache2 Web服务器充当映射地址myapplication的反向代理。 mydomain.com到服务器的IP。这是通过etc/apache2/sites-enabled/myapplication.conf

中的虚拟主机配置完成的
<VirtualHost *:80>

        ServerName myapplication.mydomain.com

        <LocationMatch "^/">
                AllowOverride None
                Require all granted
                Options +Indexes
        </LocationMatch>

        ErrorLog /home/mysuer/myapplication/logs/myapplication.error.log
        LogLevel trace1
        CustomLog /home/mysuer/myapplication/logs/myapplication.access.log
combined

        ProxyPreserveHost On
        ProxyPass / http://localhost:4567/
        ProxyPassReverse / http://localhost:4567/

</VirtualHost>

现在,我需要通过将相同的端口4567映射到新的URL www.mydomain.com/myapplication

来更改映射的URL。

我尝试了.conf文件的许多变体,例如:

<VirtualHost *:80>

        ServerName www.mydomain.com

        <LocationMatch "^/myapplication">
                AllowOverride None
                Require all granted
                Options +Indexes
        </LocationMatch>

        ErrorLog /home/mysuer/myapplication/logs/myapplication.error.log
        LogLevel trace1
        CustomLog /home/mysuer/myapplication/logs/myapplication.access.log
combined

        ProxyPreserveHost On
        ProxyPass /myapplication http://localhost:4567/
        ProxyPassReverse /myapplication http://localhost:4567/

</VirtualHost>

在所有更改中,/home/mysuer/myapplication/logs下的日志文件中没有任何消息

每当我从远程浏览器访问URL时,在Apache的error.log file中,都会收到如下消息:

[Fri Oct 25 10:22:44.180506 2019] [autoindex:error] [pid 29016:tid 139846702044928] [client <SERVER IP>:18917] AH01276: Cannot serve directory /var/www/html/: No matching Director
yIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive

有人可以建议正确的语法来更改上述.conf文件吗?

我预先声明我对Apache2虚拟主机配置没有经验:我只是继承了.conf文件,并尝试通过反复试验对其进行修改。

0 个答案:

没有答案