嵌入Tomcat-7仅在https中运行

Sri*_*vas 6 java tomcat7

我想运行仅使用HTTPS(8443)的嵌入式tomcat.我根本不想使用8080端口.有什么想法吗?


    Connector httpsConnector = new Connector();
    httpsConnector.setPort(httpsPort);
    httpsConnector.setSecure(true);
    httpsConnector.setScheme("https");
    httpsConnector.setAttribute("keystoreFile", appBase + "/.keystore");
    httpsConnector.setAttribute("clientAuth", "false");
    httpsConnector.setAttribute("sslProtocol", "TLS");
    httpsConnector.setAttribute("SSLEnabled", true);

    Tomcat tomcat = new Tomcat();
    tomcat.getService().addConnector(httpsConnector);
    tomcat.setPort(8080);
    Connector defaultConnector = tomcat.getConnector();
    defaultConnector.setRedirectPort(8443);

    tomcat.setBaseDir(".");
    tomcat.getHost().setAppBase(appBase);

    StandardServer server = (StandardServer) tomcat.getServer();
    AprLifecycleListener listener = new AprLifecycleListener();
    server.addLifecycleListener(listener);

谢谢

Chr*_*ris 2

您必须删除 [tomcat-dir]/conf/server.xml 中定义的连接器,该连接器将其绑定到 8080,并为 HTTPS 有一个单独的连接器。