不同机器的Apache 2.2到Tomcat虚拟主机不工作

时间:2015-08-15 16:57:30

标签: java tomcat7 virtualhost apache2.2

我有一个场景,其中对Tomcat服务器(Application Server)的所有请求都应该通过Apache 2.2(Web服务器)。 两台服务器都应该在两台不同的机器上。 出于安全原因,这两台计算机不在同一个域或网络上。

我必须使用如下所示的虚拟主机设置,因为这已经被我公司的其他开发人员使用并且经过全面测试并且工作正常。

 <VirtualHost *:*>
      #Full Computer Name with port if its not 80
      ServerName Full_Name_OF_Computer
      ServerAlias Full_Name_OF_Computer

      LogFormat "%h %l %u %t \"%r\" %s %b %D" app
      CustomLog logs/app-access.log app

      SSLProxyEngine On

      RewriteEngine on
      RewriteLogLevel 5
      RewriteLog logs/rewrite.log

      # Root URL handling
      RewriteRule ^\/app\/?$ /app/launch.jsp [R,L]
      RewriteRule ^\/app\/?$ ajp://Full_Name_OF_Computer:8009/app [P,L]

      # Dynamic content
      RewriteRule ^/app/(.+\.(?:jsp|do|rpc).*)$ ajp://Full_Name_OF_Computer:8009/app/$1 [P,L]

      # This must be the location where application is deployed
      # SHOULD THIS BE THE LOCATION WITH IN THE APPLICATION SEVER OR THE LOCATION PATH TO THE APPLICATION SERVER FROM WEB SERVER??
      Alias /app "D:\apache-tomcat-7.0.63\webapps\app"
      <Directory "D:\apache-tomcat-7.0.63\webapps\app">
          Options FollowSymLinks
          AllowOverride None
          Allow from all

          ExpiresActive on
          ExpiresDefault "access plus 2 months"
          ExpiresByType application/x-javascript  "access plus 2 months"
          ExpiresByType application/javascript  "access plus 2 months"
          ExpiresByType text/javascript  "access plus 2 months"
          ExpiresByType text/css  "access plus 2 months"
          ExpiresByType image/gif "access plus 2 months"
          ExpiresByType image/jpeg "access plus 2 months"
          ExpiresByType image/png "access plus 2 months"
          ExpiresByType image/x-icon "access plus 2 months"

          AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript text/json application/x-javascript
      </Directory>
  </VirtualHost>

如果我在同一台机器上安装了apache和tomcat服务器,这对我来说很好。但是,如果我在不同的机器上安装Apache和Tomcat服务器(根据需要),那么我对HTTPD.conf进行了一些更改,之后我无法通过Apache访问应用程序。可以通过Appplication URL从WebServer访问该应用程序(使用端口8080)。

有人可以帮我指出我做错了吗?

在Tomcat上更改WebServerFullName,ApplicationServerFullName和应用程序部署文件夹的网络路径后,新的虚拟主机设置为:

 <VirtualHost *:*>
      #Full Computer Name with port if its not 80
      ServerName Web_Server_Ful_Name
      ServerAlias Web_Server_Ful_Name

      LogFormat "%h %l %u %t \"%r\" %s %b %D" app
      CustomLog logs/app-access.log app

      SSLProxyEngine On

      RewriteEngine on
      RewriteLogLevel 5
      RewriteLog logs/rewrite.log

      # Root URL handling
      RewriteRule ^\/app\/?$ /app/launch.jsp [R,L]
      RewriteRule ^\/app\/?$ ajp://ApplicationServerFullName:8009/app [P,L]

      # Dynamic content
      RewriteRule ^/app/(.+\.(?:jsp|do|rpc).*)$ ajp://ApplicationServerFullName:8009/app/$1 [P,L]

      # This must be the location where application is deployed
      # SHOULD THIS BE THE LOCATION WITH IN THE APPLICATION SEVER OR THE LOCATION PATH TO THE APPLICATION SERVER FROM WEB SERVER??
      Alias /app "\\ApplicationServerFullName\cim$\apache-tomcat-7.0.63\webapps\app"
      <Directory "\\ApplicationServerFullName\cim$\apache-tomcat-7.0.63\webapps\app">
          Options FollowSymLinks
          AllowOverride None
          Allow from all

          ExpiresActive on
          ExpiresDefault "access plus 2 months"
          ExpiresByType application/x-javascript  "access plus 2 months"
          ExpiresByType application/javascript  "access plus 2 months"
          ExpiresByType text/javascript  "access plus 2 months"
          ExpiresByType text/css  "access plus 2 months"
          ExpiresByType image/gif "access plus 2 months"
          ExpiresByType image/jpeg "access plus 2 months"
          ExpiresByType image/png "access plus 2 months"
          ExpiresByType image/x-icon "access plus 2 months"

          AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript text/json application/x-javascript
      </Directory>
  </VirtualHost>

我对Tomcat上应用程序部署文件夹的网络路径有疑问,因为由于2台计算机不在同一网络上,网络管理员不得不考虑 DOLLAR($)<给我一条奇怪的路径/ strong>登录, \ ApplicationServerFullName \ cim $ \ apache-tomcat-7.0.63 \ webapps \ app (可通过浏览器从WebServer访问)

其他细节是:

Tomcat Server.xml AJP设置:

<!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 

error.log中:

[Fri Aug 14 18:27:07 2015] [debug] mod_proxy_ajp.c(45): proxy: AJP: canonicalising URL //ApplicationServerFullName:8009/app/launch.jsp
[Fri Aug 14 18:27:07 2015] [debug] proxy_util.c(1532): [client 10.16.1.3] proxy: *: found reverse proxy worker for ajp://ApplicationServerFullName:8009/app/launch.jsp
[Fri Aug 14 18:27:07 2015] [debug] mod_proxy.c(1036): Running scheme ajp handler (attempt 0)
[Fri Aug 14 18:27:07 2015] [debug] mod_proxy_ajp.c(726): proxy: AJP: serving URL ajp://ApplicationServerFullName:8009/app/launch.jsp
[Fri Aug 14 18:27:07 2015] [debug] proxy_util.c(2018): proxy: AJP: has acquired connection for (*)
[Fri Aug 14 18:27:07 2015] [debug] proxy_util.c(2074): proxy: connecting ajp://ApplicationServerFullName:8009/app/launch.jsp to ApplicationServerFullName:8009
[Fri Aug 14 18:27:07 2015] [debug] proxy_util.c(2200): proxy: connected /app/launch.jsp to ApplicationServerFullName:8009
[Fri Aug 14 18:27:07 2015] [debug] proxy_util.c(2451): proxy: AJP: fam 2 socket created to connect to *
[Fri Aug 14 18:27:07 2015] [debug] ajp_header.c(224): Into ajp_marshal_into_msgb
[Fri Aug 14 18:27:07 2015] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[0] [Accept] = [text/html, application/xhtml+xml, */*]
[Fri Aug 14 18:27:07 2015] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[1] [Accept-Language] = [nl-NL]
[Fri Aug 14 18:27:07 2015] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[2] [User-Agent] = [Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko]
[Fri Aug 14 18:27:07 2015] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[3] [Accept-Encoding] = [gzip, deflate]
[Fri Aug 14 18:27:07 2015] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[4] [Host] = [Web_Server_Ful_Name]
[Fri Aug 14 18:27:07 2015] [debug] ajp_header.c(290): ajp_marshal_into_msgb: Header[5] [Connection] = [Keep-Alive]
[Fri Aug 14 18:27:07 2015] [debug] ajp_header.c(461): ajp_marshal_into_msgb: Done
[Fri Aug 14 18:27:07 2015] [debug] mod_proxy_ajp.c(270): proxy: APR_BUCKET_IS_EOS
[Fri Aug 14 18:27:07 2015] [debug] mod_proxy_ajp.c(275): proxy: data to read (max 8186 at 4)
[Fri Aug 14 18:27:07 2015] [debug] mod_proxy_ajp.c(290): proxy: got 0 bytes of data
[Fri Aug 14 18:27:07 2015] [error] (OS 10054)An existing connection was forcibly closed by the remote host.  : ajp_ilink_receive() can't receive header
[Fri Aug 14 18:27:07 2015] [error] ajp_read_header: ajp_ilink_receive failed
[Fri Aug 14 18:27:07 2015] [error] (120006)APR does not understand this error code: proxy: read response failed from (null) (*)
[Fri Aug 14 18:27:07 2015] [debug] proxy_util.c(2036): proxy: AJP: has released connection for (*)

Rewrite.log

10.16.1.3 - - [14/Aug/2015:18:27:07 +0200] [Web_Server_Ful_Name/sid#79a028][rid#7aed50/initial] (2) init rewrite engine with requested uri /app/launch.jsp
10.16.1.3 - - [14/Aug/2015:18:27:07 +0200] [Web_Server_Ful_Name/sid#79a028][rid#7aed50/initial] (3) applying pattern '^\\/app\\/?$' to uri '/app/launch.jsp'
10.16.1.3 - - [14/Aug/2015:18:27:07 +0200] [Web_Server_Ful_Name/sid#79a028][rid#7aed50/initial] (3) applying pattern '^\\/app\\/?$' to uri '/app/launch.jsp'
10.16.1.3 - - [14/Aug/2015:18:27:07 +0200] [Web_Server_Ful_Name/sid#79a028][rid#7aed50/initial] (3) applying pattern '^/app/(.+\\.(?:jsp|do|rpc).*)$' to uri '/app/launch.jsp'
10.16.1.3 - - [14/Aug/2015:18:27:07 +0200] [Web_Server_Ful_Name/sid#79a028][rid#7aed50/initial] (2) rewrite '/app/launch.jsp' -> 'ajp://ApplicationServerFullName:8009/app/launch.jsp'
10.16.1.3 - - [14/Aug/2015:18:27:07 +0200] [Web_Server_Ful_Name/sid#79a028][rid#7aed50/initial] (2) forcing proxy-throughput with ajp://ApplicationServerFullName:8009/app/launch.jsp
10.16.1.3 - - [14/Aug/2015:18:27:07 +0200] [Web_Server_Ful_Name/sid#79a028][rid#7aed50/initial] (1) go-ahead with proxy request proxy:ajp://ApplicationServerFullName:8009/app/launch.jsp [OK]

的access.log

10.16.1.3 - - [14/Aug/2015:18:27:07 +0200] "GET /app/launch.jsp HTTP/1.1" 503 323 0

有人可以帮我解决这个问题,因为我没有时间进行这项实施,而且我在网上看了很多类似的问题,但我找不到任何解决方案。

非常感谢。

0 个答案:

没有答案