[英]Port not redirected in embedded tomcat
我遇到需要將請求從非SSL
端口重定向到SSL
端口的情況。 我想出了以下代碼,但它似乎沒有重定向。
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.