我试图在Ubuntu 14.04上通过Apache 2设置代理。 我有两个代理我想要使用。 一个是在本地运行的Ruby瘦服务器。 另一个是电话统计页面。 我已经configuration了一个conf文件,内容如下:
<VirtualHost *:80> Redirect permanent / <ssl_site> </VirtualHost> <VirtualHost _default_:443> --snip certificate info-- --snip contact info-- LogLevel debug --snip log info-- ProxyRequests Off ProxyPreserveHost On <Proxy *> Order Allow,Deny Allow from all </Proxy> SSLProxyEngine On <Location /> ProxyPass <Ruby thin server> ProxyPassReverse <Ruby thin server> </Location> <Location /phonestats/> RequestHeader set Authorization "Basic <Base64 username:password>" ProxyPreserveHost On ProxyPass http://phonestats:port/ ProxyPassReverse http://phonestats:port/ </Location> </VirtualHost>
但是,当我尝试去/ phonestats /我得到一个404错误。 错误日志显示如下:
[Tue Apr 21 10:27:21.042723 2015] [proxy:debug] [pid 3138:tid 139930961352576] proxy_util.c(1694): AH00925: initializing worker <phonestats url> shared [Tue Apr 21 10:27:21.042727 2015] [proxy:debug] [pid 3138:tid 139930961352576] proxy_util.c(1734): AH00927: initializing worker <phonestats url> local [Tue Apr 21 10:27:21.042736 2015] [proxy:debug] [pid 3138:tid 139930961352576] proxy_util.c(1769): AH00930: initialized pool in child 3138 for (phonestats) min=0 max=25 smax=25 [Tue Apr 21 10:27:21.043273 2015] [proxy:debug] [pid 3137:tid 139930961352576] proxy_util.c(1694): AH00925: initializing worker <phonestats url> shared [Tue Apr 21 10:27:21.043277 2015] [proxy:debug] [pid 3137:tid 139930961352576] proxy_util.c(1734): AH00927: initializing worker <phonestats url> local [Tue Apr 21 10:27:21.043286 2015] [proxy:debug] [pid 3137:tid 139930961352576] proxy_util.c(1769): AH00930: initialized pool in child 3137 for (phonestats) min=0 max=25 smax=25 [Tue Apr 21 10:27:24.902951 2015] [proxy:debug] [pid 3137:tid 139930755913472] proxy_util.c(2072): [client 192.168.3.141:52496] AH00944: connecting <phonestats url> to <phonestats host> [Tue Apr 21 10:27:29.908518 2015] [proxy:debug] [pid 3137:tid 139930755913472] proxy_util.c(2206): [client 192.168.3.141:52496] AH00947: connected <phonestats path> to <phonestats host> [Tue Apr 21 10:27:29.909235 2015] [proxy:debug] [pid 3137:tid 139930755913472] proxy_util.c(2610): AH00962: HTTP: connection complete to 192.168.3.21:8081 (phonestats) [Tue Apr 21 10:27:30.120569 2015] [ssl:debug] [pid 3137:tid 139930730735360] ssl_engine_kernel.c(222): [client 192.168.3.141:52496] AH02034: Subsequent (No.5) HTTPS request received for child 0 (server <server url>), referer: <HTTP referer> [Tue Apr 21 10:27:30.120614 2015] [authz_core:debug] [pid 3137:tid 139930730735360] mod_authz_core.c(828): [client 192.168.3.141:52496] AH01628: authorization result: granted (no directives), referer: <HTTP referer> [Tue Apr 21 10:27:30.120646 2015] [proxy:debug] [pid 3137:tid 139930730735360] mod_proxy.c(1104): [client 192.168.3.141:52496] AH01143: Running scheme http handler (attempt 0), referer: <HTTP referer> [Tue Apr 21 10:27:30.120662 2015] [proxy:debug] [pid 3137:tid 139930730735360] proxy_util.c(2072): [client 192.168.3.141:52496] AH00944: connecting http://<Thin Server>/favicon.ico to <Thin Server>, referer: <HTTP referer> [Tue Apr 21 10:27:30.120668 2015] [proxy:debug] [pid 3137:tid 139930730735360] proxy_util.c(2206): [client 192.168.3.141:52496] AH00947: connected /favicon.ico to <Thin Server>, referer: <HTTP referer>
似乎在代理完成之后,它试图通过其他代理来代理信息。 我不知道如何停止这个,或者如果我甚至在写道上。
这是通过URL重写更好地解决?
问题是在我试图代理的URL中有一个查询string。 不幸的是,我从错误日志中删除了这个URL。 诀窍是做到以下几点:
ProxyPass http://phonestats:port/ nocanon