Apache反向代理:无协议处理程序


20

我正在尝试使用apache配置反向代理,但出现No protocol handler was valid for the URL错误,这是我不理解的。

这是apache的相关配置:

ProxyRequests Off
ProxyPreserveHost On

<Proxy *>
       Order deny,allow
       Allow from all
</Proxy>

ProxyPass        /gonvaled/examples/jsonrpc/output/services/ http://localhost:8000/services/
ProxyPassReverse /gonvaled/examples/jsonrpc/output/services/ http://localhost:8000/services/

请求达到apache为:

POST /gonvaled/examples/jsonrpc/output/services/EchoService.py HTTP/1.1

他们应该转发给我的内部服务,位于:

0.0.0.0:8000/services/EchoService.py

这些是日志:

==> /var/log/apache2/error.log <==
[Wed Jun 20 02:05:20 2012] [debug] proxy_util.c(1506): [client 127.0.0.1] proxy: http: found worker http://localhost:8000/services/ for http://localhost:8000/services/EchoService.py, referer: http://localhost/gonvaled/examples/jsonrpc/output/JSONRPCExample.safari.cache.html
[Wed Jun 20 02:05:20 2012] [debug] mod_proxy.c(998): Running scheme http handler (attempt 0)
[Wed Jun 20 02:05:20 2012] [warn] proxy: No protocol handler was valid for the URL /gonvaled/examples/jsonrpc/output/services/EchoService.py. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
[Wed Jun 20 02:05:20 2012] [debug] mod_deflate.c(615): [client 127.0.0.1] Zlib: Compressed 614 to 373 : URL /gonvaled/examples/jsonrpc/output/services/EchoService.py, referer: http://localhost/gonvaled/examples/jsonrpc/output/JSONRPCExample.safari.cache.html

==> /var/log/apache2/access.log <==
127.0.0.1 - - [20/Jun/2012:02:05:20 +0200] "POST /gonvaled/examples/jsonrpc/output/services/EchoService.py HTTP/1.1" 500 598 "http://localhost/gonvaled/examples/jsonrpc/output/JSONRPCExample.safari.cache.html" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.162 Safari/535.19"

Answers:


26

我发现了问题。该proxy_http模块也需要在Apache中激活(我只有proxy_htmland proxy


23

对我来说,httpd 2.4发生这种情况是因为我错过了结尾的斜线:

不工作:

    <Proxy balancer://mycluster>
        BalancerMember http://192.168.111.7
        BalancerMember http://192.168.111.80
    </Proxy>
    ProxyPass / balancer://mycluster
    ProxyPassReverse / balancer://mycluster

工作了!

    <Proxy balancer://mycluster>
        BalancerMember http://192.168.111.7
        BalancerMember http://192.168.111.80
    </Proxy>
    ProxyPass / balancer://mycluster/
    ProxyPassReverse / balancer://mycluster/

/末尾添加)


对我而言,末尾的Apache 2.2.15 <kbd> / </ kbd>起作用。谢谢!

帮助我使用Apache / 2.4.10(Debian)。这需要记录在案!错误消息非常晦涩
DeveloperChris

2

对于那些正在寻找答案的人,另一种可能性是也缺少要后端的URL服务名称。使用LogLevel Debug以及mod_proxy和mod_proxy_fcgi,我看到了以下内容:

[debug] proxy: fgci: found worker fgci://127.0.0.1:9000/var/www/html/.../index.php [debug] mod_proxy.c(1026): Running scheme fgci handler (attempt 0) [debug] mod_proxy_fcgi.c(800): [client ...] AH01076: url: fgci://127.0.0.1:9000/var/www/html/.../index.php proxyname: (null) proxyport: 0 [debug] mod_proxy_fcgi.c(805): [client ...] AH01077: declining URL fgci://127.0.0.1:9000/var/www/html/.../index.php [warn] proxy: No protocol handler was valid for the URL /.../index.php. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

值得庆幸的mod_proxy_fastcgi(我使用RHEL6上的Apache 2.2的一个补丁包)的代码可在https://github.com/ceph/mod-proxy-fcgi/blob/master/mod_proxy_fcgi.c#L805,这是本一段代码:

if (strncasecmp(url, "fcgi:", 5) != 0) {
    ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(01077) "declining URL %s", url);
    return DECLINED;
}

如果您仔细查看日志-我只是在查看发出该消息的代码时才注意到它-您会发现应该fcgi://...拼写为fgci://...

因此,当您看到declining URL它时,意味着:

  • 您没有加载接受该服务的处理程序(例如fcgi :),或者
  • 您没有正确输入服务名称。

1
我之所以投票,是因为该答案的“当您看到此错误时,意味着...”部分。我认为这应该会引导大多数搜索者朝正确的方向发展。
threeve
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.