【发布时间】:2016-08-24 06:13:24
【问题描述】:
我无法为上下文 tomcat 应用程序正确配置我的 apache2 反向代理。
我在浏览器中使用网址 www.projet-okinawa.ch 从外部访问应用程序。
我的 tcp 端口 80 被 iptables 路由到 8080。
(sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080)
我定义了一个虚拟主机从端口 8080 捕获 url www.projet-okinawa.ch 并将请求重定向到 ssl 端口。
<VirtualHost *:8080>
ServerName www.projet-okinawa.ch
ServerAlias projet-okinawa.ch
Redirect permanent / https://www.projet-okinawa.ch:8443/
</VirtualHost>
I defined a second virtual host to catch the same url from the port 8443 that enable ssl and manage the reverse proxy.
<VirtualHost *:8443>
ServerName www.projet-okinawa.ch
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://web.projet-okinawa.org:8081/okinawa
ProxyPassReverse / http://web.projet-okinawa.org:8081/okinawa
<Location />
Order allow,deny
Allow from all
</Location>
SSLCertificateFile /etc/letsencrypt/live/os-vps276.projet-okinawa.org/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/os-vps276.projet-okinawa.org/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/os-vps276.projet-okinawa.org/chain.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
您可能会注意到 Web 应用程序上下文设置为 /okinawa。
我的 tomcat 配置正在监听 8080、8081 和 8443 tcp 端口。
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
proxyName="www.projet-okinawa.ch" proxyPort="8443" scheme="https" />
<Connector port="8443"
protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150"
SSLEnabled="true"
scheme="https"
secure="true"
clientAuth="false"
sslProtocol="TLS"
URIEncoding="UTF-8"
keystoreFile={keystore} keystorePass={password} />
Web 应用程序在上下文 /okinawa 下的 Catalina localhost 引擎上执行。上下文不是通过使用上下文描述符而是通过自动部署定义的。应用程序正确执行,并且可以使用端口 8080 在内部进行访问(例如:http://web.projet-okinawa.org/okinawa/participatewithus.html)。
当使用 www.projet-okinawa.ch 通过代理访问它时,我得到一个 HTTP 状态 404 - /okinawaokinawa/ 异常。
我测试了许多不同的方式来配置反向代理,但都没有成功。我不明白为什么返回的 url 不支持 www.projet-okinawa.ch 没有似乎重复的上下文。
欢迎任何帮助。
【问题讨论】:
标签: url-redirection reverse-proxy tomcat8 apache2.4