我有两个在tomcat 7.0下运行的Web应用程序
-
https:// secure.example.com:8443
-
http:// insecure.example.com:8080
它们在server.xml中有两个单独的“主机”记录(不同的域,不同的位置) .
I need first one to be available via HTTPS only. In other words I need insecure requests to secure application to be redirected to secure port. But insecure application still must be available via HTTP.
-
http:// insecure.example.com:8080 - 好的
-
https:// secure.example.com:8443 - 好的
-
http:// secure.example.com:8080 - > https:// secure.example.com:8443
我知道可以在不安全的连接器(server.xml)中指定“redirectPort”,但随后对任何应用程序(域)的HTTP请求将被重定向到安全端口 .
是否可以使用单个tomcat实例进行配置?
1 回答
这可以通过在conf / server.xml中设置单独的“Service”元素来实现 .
比如你有
现在添加其他服务部分
因此,安全应用程序将无法通过不安全的连接提供,因为HTTP端口由另一个服务提供服务 .
关于HTTP(8080) - > HTTPS(8443)重定向,可能在这种配置中有更好的方法,但可以在“Catalina”服务中设置名称=“secure.example.com”的第二个“主机”部分,并部署一些包含简单servlet的Web应用程序,将任何请求重定向到指定的安全URL .
例如
web.xml中
RedirectServlet.java