0

我一直在尝试为我的 Java Web 项目配置 Tomcat 10.0.4 和 IntelliJ Idea。但是,我无法在端口 8443 上使用 SSL 运行该项目。我还在 tomcat bin 文件夹中包含了 Tomcat Native Library dll。在 IntelliJ 的构建配置设置下,我还包含了 HTTPS 的端口号。

在构建和运行服务器后,https://localhost:8443 会按预期工作。但是,当我尝试使用本地 IP 地址 (192.168.1.2) 或通过我的外部 IP 地址访问 Web 服务器时,chrome spits ERR_CONNECTION_REFUSED。通过这两种方式,端口 80 都可以正常工作。

我为端口 80、443 和 8443 启用了端口转发(考虑到端口 80 可以正常工作),但 8443 不起作用。在 Windows 10 上,我还在防火墙设置中允许入站和出站连接到 8443。

以下是我的 server.xml

<?xml version="1.0" encoding="UTF-8"?>
<Server port="-1" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
 <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" useAprConnector="true" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector port="8080" protocol="HTTP/1.1"
                executor="tomcatThreadPool"
               connectionTimeout="20000"
                redirectPort="8443"
                useIPVHosts="true" 
                address="0.0.0.0"/>
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
               maxThreads="150" SSLEnabled="true" URIEncoding="UTF-8" 
               secure="true" SSLEngine="true" scheme="https"  clientAuth="false"
               sslProtocol="TLS">
        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
        <SSLHostConfig>
                <Certificate             
                        certificateKeyFile="conf/privkey1.pem"
                        certificateFile="conf/cert1.pem"
                        certificateChainFile="conf/chain1.pem"
                type="RSA" />
        </SSLHostConfig>
    </Connector>

    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" 
               resolveHosts="true"/>

      </Host>
    </Engine>
  </Service>
</Server>

任何帮助将不胜感激!

更新(04/24/2021 @ 5:07 PM 以下是启动时的日志消息:

NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
24-Apr-2021 17:00:26.698 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Listener] failed to set property [useAprConnector] to [true]
24-Apr-2021 17:00:26.811 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Connector] failed to set property [SSLEngine] to [true]
24-Apr-2021 17:00:26.811 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Connector] failed to set property [clientAuth] to [false]
24-Apr-2021 17:00:26.812 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Connector] failed to set property [sslProtocol] to [TLS]
24-Apr-2021 17:00:26.868 WARNING [main] org.apache.tomcat.util.digester.SetPropertiesRule.begin Match [Server/Service/Engine/Host/Valve] failed to set property [resolveHosts] to [true]
24-Apr-2021 17:00:26.871 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/10.0.4
24-Apr-2021 17:00:26.871 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Mar 5 2021 11:07:15 UTC
24-Apr-2021 17:00:26.871 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 10.0.4.0
24-Apr-2021 17:00:26.871 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 10
24-Apr-2021 17:00:26.872 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.0
24-Apr-2021 17:00:26.872 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
24-Apr-2021 17:00:26.872 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jdk-11.0.10
24-Apr-2021 17:00:26.872 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           11.0.10+8-LTS-162
24-Apr-2021 17:00:26.872 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
24-Apr-2021 17:00:26.872 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Users\MicroTechTon\AppData\Local\JetBrains\IntelliJIdea2021.1\tomcat\6454be16-6e63-47f0-9175-b6e43d48845f
24-Apr-2021 17:00:26.872 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         C:\Program Files\Apache Software Foundation\Tomcat 10.0
24-Apr-2021 17:00:26.873 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.lang=ALL-UNNAMED
24-Apr-2021 17:00:26.873 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.io=ALL-UNNAMED
24-Apr-2021 17:00:26.873 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util=ALL-UNNAMED
24-Apr-2021 17:00:26.873 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.base/java.util.concurrent=ALL-UNNAMED
24-Apr-2021 17:00:26.874 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
24-Apr-2021 17:00:26.874 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Users\MicroTechTon\AppData\Local\JetBrains\IntelliJIdea2021.1\tomcat\6454be16-6e63-47f0-9175-b6e43d48845f\conf\logging.properties
24-Apr-2021 17:00:26.874 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
24-Apr-2021 17:00:26.874 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
24-Apr-2021 17:00:26.874 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
24-Apr-2021 17:00:26.874 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
24-Apr-2021 17:00:26.874 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.password.file=C:\Users\MicroTechTon\AppData\Local\JetBrains\IntelliJIdea2021.1\tomcat\6454be16-6e63-47f0-9175-b6e43d48845f\jmxremote.password
24-Apr-2021 17:00:26.874 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.access.file=C:\Users\MicroTechTon\AppData\Local\JetBrains\IntelliJIdea2021.1\tomcat\6454be16-6e63-47f0-9175-b6e43d48845f\jmxremote.access
24-Apr-2021 17:00:26.874 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
24-Apr-2021 17:00:26.875 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
24-Apr-2021 17:00:26.875 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
24-Apr-2021 17:00:26.875 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
24-Apr-2021 17:00:26.875 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Users\MicroTechTon\AppData\Local\JetBrains\IntelliJIdea2021.1\tomcat\6454be16-6e63-47f0-9175-b6e43d48845f
24-Apr-2021 17:00:26.875 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 10.0
24-Apr-2021 17:00:26.875 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 10.0\temp
24-Apr-2021 17:00:26.879 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.2.28] using APR version [1.7.0].
24-Apr-2021 17:00:26.880 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
24-Apr-2021 17:00:26.884 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1k  25 Mar 2021]
24-Apr-2021 17:00:27.200 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-0.0.0.0-80"]
24-Apr-2021 17:00:27.228 INFO [main] org.apache.coyote.http11.AbstractHttp11Protocol.configureUpgradeProtocol The ["https-openssl-apr-8443"] connector has been configured to support negotiation to [h2] via ALPN
24-Apr-2021 17:00:27.228 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["https-openssl-apr-8443"]
24-Apr-2021 17:00:27.339 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [783] milliseconds
24-Apr-2021 17:00:27.411 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
24-Apr-2021 17:00:27.411 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/10.0.4]
24-Apr-2021 17:00:27.428 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-0.0.0.0-80"]
24-Apr-2021 17:00:27.449 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["https-openssl-apr-8443"]
24-Apr-2021 17:00:27.457 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [117] milliseconds
Connected to server
4

0 回答 0