Apache代理传递给Unix域套接字

时间:2018-07-09 10:26:29

标签: apache mod-proxy proxypass unix-socket

我需要将所有流量从指定端口转发到Apache中的Unix域套接字:

sites-enabled/000-default.conf中,我定义了一个VirtualHost:

<VirtualHost *:8091>
    ProxyRequests Off
    <Proxy *>
            Order deny,allow
            Allow from all
    </Proxy>
    ProxyPass / unix:/var/lib/jenkins/workspace/myproject/mysocket.sock|http://127.0.0.1/
    ProxyPassReverse / unix:/var/lib/jenkins/workspace/myproject/mysocket.sock|http://127.0.0.1/
</VirtualHost>

ports.conf中,我有:

Listen 80
Listen 8091

我同时启用了proxyproxy_http模组:

krzysiek:/etc/apache2$ a2enmod proxy
Module proxy already enabled
krzysiek:/etc/apache2$ a2enmod proxy_http
Module proxy already enabled

我正在使用Apache 2.4.7,官方文档指出:

  

在2.4.7及更高版本中,可以通过使用在unix:/path/lis.sock |之前加上目标的目标来支持使用Unix域套接字。

重新加载Apache时出现错误:

krzysiek:/etc/apache2$ sudo service apache2 restart
* Restarting web server apache2                                [fail] 
* The apache2 configtest failed.
AH00526: Syntax error on line 64 of /etc/apache2/sites-enabled/000-default.conf:
ProxyPass URL must be absolute!

我尝试更改:

ProxyPass / unix:/var/(...)

收件人:

ProxyPass / unix:///var/(...)

然后Apache正确重新加载,但转发不起作用,error.log说:

[proxy:warn] [pid 22436] [client 10.0.4.19:47662] AH01144: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

您能解释一下我在做什么错吗?还是如何将流量从端口正确转发到Apache上的unix套接字?

0 个答案:

没有答案