2

我有一个带有 Apache2(端口 80)和 Glassfish(端口 8080)的服务器。我想将 Apache 配置为透明地将对某个虚拟主机的请求代理到 glassfish 服务器。
我试过这个,但它不起作用:

<VirtualHost *>
ServerName tognettiimmobiliare.com
ServerAlias www.tognettiimmobiliare.com

ProxyRequests on

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

ProxyPreserveHost On

ProxyPass / http://tognettiimmobiliare.com:8080/tognettiWEB/
ProxyPassReverse / http://tognettiimmobiliare.com:8080/tognettiWEB/

</VirtualHost>

谁能告诉我为什么?谢谢

4

3 回答 3

2

我正在使用 mod_proxy 从不同的端口代理 Jenkins 和 Redmine,我的配置看起来像这样,没有<Proxy>我认为不需要的附加部分:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

ProxyPass /jenkins/ http://localhost:8080/jenkins/
ProxyPassReverse /jenkins/ http://localhost:8080/jenkins/

ProxyPass /redmine/ http://localhost:81/redmine/
ProxyPassReverse /redmine/ http://localhost:81/redmine/

有两件事要记住:

  • 代理和代理 URL 中的上下文必须相同,例如 /jenkins/ 和 .../jenkins/

  • 您不应该对代理页面使用外部 URL,因为它会尝试路由到 Internet 并从那里连接,这很慢并且防火墙可能会阻止该端口。使用本地机器名称或 IP。

于 2012-08-17T23:06:46.793 回答
1

我使用一个简单的 VirtualHost,就像这样,它可以工作。

<VirtualHost *:80>
#   ServerName www.itmanx.com

    ProxyPass / http://www.itmanx.int/
    ProxyPassReverse / http://www.itmanx.int/
</VirtualHost>

确保你有mod_proxymod_proxy_http加载

于 2012-01-29T15:15:15.640 回答
0

我通过转到 Configurations -> server-config -> HTTP Service -> Http Listeners -> jk-listener 在 Glassfish 上启用了 JK 并启用了它。

然后在我的 Apache 配置中设置以这种方式代理,以便 SSL 数据也被传输。

<Location /util>
SSLOptions +StdEnvVars +ExportCertData
ProxyPass ajp://localhost:8004/util
</Location>

不过有一个警告,mod_proxy_wstunnel似乎不适用于此,或者至少我还没有发现如何使用 WSS 并且https://issues.apache.org/bugzilla/show_bug.cgi?id=55320需要 2.4。 10 尚未发布。

于 2014-06-26T01:52:02.167 回答