Apache 2.2 反向代理没有按预期工作?

0 proxy apache-2.2

我已经根据我在apache 2.2 手册中阅读的内容相应地配置了我的 apache 。下面以我的配置为例。

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"
Run Code Online (Sandbox Code Playgroud)

每次我访问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)
 ...
Run Code Online (Sandbox Code Playgroud)

每次访问时都会收到以下日志消息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
...
Run Code Online (Sandbox Code Playgroud)

似乎代理不起作用......这让我发疯......

Joh*_*ers 5

根据你的描述,我认为你应该有以下几点:

ProxyPass "/sandbox" "http://localhost:8080/home/kwokfu/sandbox"
ProxyPassReverse "/sandbox" "http://localhost:8080/home/kwokfu/sandbox"
Run Code Online (Sandbox Code Playgroud)