gpt4 book ai didi

java - 嵌入 Tomcat-7 以仅在 https 中运行

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:29:58 26 4
gpt4 key购买 nike

我想运行仅使用 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);

谢谢

最佳答案

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

关于java - 嵌入 Tomcat-7 以仅在 https 中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11824148/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com