我正在尝试启动嵌入式Jetty并仅启用SSL。这样用户只能在端口8443上访问它。
代码如下所示:
HttpConfiguration http_config = new HttpConfiguration();
http_config.setSecureScheme( "https" );
http_config.setSecurePort( 8443 );
http_config.setOutputBufferSize( 32768 );
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory
.setKeyStorePath( "./path_to_keystore/keystore.p12" );
sslContextFactory.setKeyStorePassword( "pass" );
sslContextFactory
.setTrustStorePath( "./path_to_truststore/trustore.jks" );
sslContextFactory.setTrustStorePassword( "changeit" );
HttpConfiguration https_config = new HttpConfiguration( http_config );
https_config.addCustomizer( new SecureRequestCustomizer() );
ServerConnector https = new ServerConnector( m_jettyServer, new SslConnectionFactory( sslContextFactory,
"http/1.1" ), new HttpConnectionFactory( https_config ) );
https.setPort( 8443 );
https.setIdleTimeout( 500000 );
m_jettyServer.setConnectors( new Connector[] { https } );
m_jettyServer.setHandler(createHandlerFromWebAppContext());
Jetty服务器处理程序是应用程序的web.xml。
在我执行上述操作后,我尝试访问
https://www.my_web_app_localhost:8443
上的网络应用,但此端口没有网页。
然后我正在访问
http://www.my_web_app_localhost:8888
,由于某种原因,可以访问该网页。
我真的很困惑,因为我明确设置了端口。我无法理解为什么可以在8888访问该应用程序。
有人可以帮我理解上述内容吗?