[英]Port not redirected in embedded tomcat
I have a situation where i need to redirect requests from a non SSL
port to an SSL
port. 我遇到需要将请求从非
SSL
端口重定向到SSL
端口的情况。 I came up with the following code but it doesn't seem to redirect. 我想出了以下代码,但它似乎没有重定向。
baseConnector = tomcat.getConnector();
if (sslEnabled) {
sslConnector = new Connector();
sslConnector.setAttribute("keyAlias", "tomcat");
sslConnector.setAttribute("keystorePass", "mypassword");
sslConnector.setAttribute("keystoreFile", "pathtofile");
sslConnector.setAttribute("clientAuth", "false");
sslConnector.setAttribute("sslProtocol", "TLS");
sslConnector.setAttribute("SSLEnabled", true);
sslConnector.setProtocol("org.apache.coyote.http11.Http11NioProtocol");
sslConnector.setSecure(true);
sslConnector.setScheme("https");
sslConnector.setPort(8443);
tomcat.getService().addConnector(sslConnector);
baseConnector.setRedirectPort(8443);
}
似乎我必须向上下文添加安全约束才能从非SSL端口重定向到SSL端口
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.