我根据我在Apache 2.2 手册。以下是我的配置示例。
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass "/home/kwokfu/sandbox" "http://localhost:8080/sandbox"
ProxyPassReverse "/home/kwokfu/sandbox" "http://localhost:8080/sandbox"
每次我访问http://localhost:8080/sandbox
服务器时,它仍然会将我引导回本地主机的默认文档根目录,而不是我在代理配置中指定的目录。
我不知道我在这里做错了什么,非常感谢任何帮助!
供您参考,我编译了我的代理模块如下:
$ apxs -cia mod_proxy.c proxy_util.c
$ apxs -cia mod_proxy_http.c
$ apachectl -M
...
proxy_module (shared)
proxy_http_module (shared)
...
每次访问时都会收到以下日志消息http://localhost:8080/sandbox
:
"GET /sandbox HTTP/1.1" 404 206 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.13) Gecko/2009080315 Ubuntu/9.04 (jaunty) Firefox/3.0.13"
...
[debug] proxy_util.c(1806): proxy: grabbed scoreboard slot 0 in child 11225 for worker http://localhost:8080/sandbox
[debug] proxy_util.c(1825): proxy: worker http://localhost:8080/sandbox already initialized
[debug] proxy_util.c(1922): proxy: initialized single connection worker 0 in child 11225 for (localhost)
[debug] proxy_util.c(1806): proxy: grabbed scoreboard slot 1 in child 11225 for worker proxy:reverse
[debug] proxy_util.c(1825): proxy: worker proxy:reverse already initialized
[debug] proxy_util.c(1922): proxy: initialized single connection worker 1 in child 11225 for (*)
[debug] proxy_util.c(1791): proxy: worker http://localhost:8080/sandbox already initialized
[debug] proxy_util.c(1791): proxy: worker http://localhost:8080/sandbox already initialized
...
[error] [client 127.0.0.1] File does not exist: /opt/apache2/2.2.12/htdocs/sandbox
...
好像代理不起作用......这让我发疯了......
答案1
根据你的描述,我认为你应该有以下情况:
ProxyPass "/sandbox" "http://localhost:8080/home/kwokfu/sandbox"
ProxyPassReverse "/sandbox" "http://localhost:8080/home/kwokfu/sandbox"
答案2
您访问的是错误的 URI。您应该http://localhost/sandbox然后代理 Apache 实例应将请求定向到监听端口 8080 的实例。当然,该实例也必须进行配置。您是否为此虚拟主机设置了 DocumentRoot?