我的产品中有Apache HTTPD服务器,我需要将AJP代理添加到某个特定的应用程序中。
Tomcat AJP端口是8009,而Tomcat HTTP端口是8080(SSLterminal在Apache中)。 这是我需要configuration的AJP代理。
<Directory /app> AuthType None Allow from all Satisfy any AllowOverride None Options None FollowSymLinks </Directory> <Proxy http://localhost:8080/app > AuthType None Allow from all Order Deny,Allow Satisfy any Options None FollowSymLinks </Proxy> ProxyPass /app ajp://localhost:8009/app <Location /app> ProxyPassReverse ajp://localhost:8009/app </Location>
问题:应该在<Proxy … >
configuration什么? <Proxy http://localhost:8080/app >
或<Proxy ajp://localhost:8009/app >
新增澄清。 整个configuration包含根configuration(见下文)。
我只需要添加AJP代理到一些特定的应用程序。
<Directory /> Deny from all Allow from localhost Order Deny,Allow AuthType Basic Require valid-user AllowOverride None Satisfy any Options None FollowSymLinks </Directory> <Proxy *> Deny from all Order Deny,Allow AuthType Basic Require valid-user Satisfy any Options None FollowSymLinks </Proxy>
好的,您对Apacheconfiguration有一些误解,需要纠正。
<Directory>
块指的是绝对文件系统path。 不是URIpath或相对于文档根目录的path。 代理时,如David Hutchinson所述,您应该使用<Location>
块代替。 <Proxy>
块(几乎)专门用于configuration正向代理, 而不是反向代理。 删除这些块,你不需要它们。 再次使用<Location>
块。 <Location>
使用ProxyPass
或ProxyPassReverse
。 虽然它是有效的,但可能使事情变得复杂。 只需使用这些指令的两个参数版本即可。 另外,除非你有理由不这样做,否则在这两个指令中使用尾部斜线。 位置块的顺序可能需要颠倒(我不记得正确顺序的头顶),但是从一些事情开始:
ProxyPass /app/ ajp://localhost:8009/app/ ProxyPassReverse /app ajp://localhost:8009/app/ <Location /> Order Allow,Deny Allow from localhost AuthType Basic Require valid-user </Location> <Location /app/> Allow from all </Directory>
我已经删除了他们是默认的指令。
你根本不需要“<代理”块来做你想做的事情。
ProxyPass和ProxyPassReverse指令是您所需要的。 为了便于阅读,我build议要么坚持两个位置块,要么坚持。
如果您需要为您的应用程序pathconfiguration不同的设置,例如客户端证书身份validation,请使用位置(或位置匹配)块,就像您已经在configuration中一样。
你可以使用<Proxy *>
。 我认为这样会很好。