Jetty9 实战

Introduction

Jetty9 实战_第1张图片

Quick Start

Configuration

Contexts

Setting Context Path

  • Naming Convention
myapp.war /myapp
ROOT.war /
ROOT-foot.war Virtual Host:football ContextPath:/

- Deployer Configuration

Virtual Hosts

SSL

  • password (OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4)
  • keyPassword (OBF:1u2u1wml1z7s1z7a1wnl1u2g)
  • trustPassword (OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4)

Certificate

  • 生成一套新的公私钥键值对
openssl genrsa -aes128 -out jetty.key
  • 导出自签发的crt文件
openssl req -new -x509 -b2048 -sha256 -key jetty.key -out jetty.crt
  • 将证书导入到本地的keystore中:
keytool -keystore keystore -import -alias jetty -file jetty.crt -trustcacerts

Connector

在jetty的jetty-https配置文件中已经默认为我们设置有一个专门服务于HTTPS的Connector,可以用如下方式引入:
#===========================================================
# SSL Context
# Create the keystore and trust store for use by
# HTTPS and SPDY
#-----------------------------------------------------------
jetty.keystore=etc/keystore
jetty.keystore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
jetty.keymanager.password=OBF:1u2u1wml1z7s1z7a1wnl1u2g
jetty.truststore=etc/keystore
jetty.truststore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
jetty.secure.port=8443
etc/jetty-ssl.xml

#===========================================================
# HTTPS Connector
# Must be used with jetty-ssl.xml
#-----------------------------------------------------------
jetty.https.port=8443
etc/jetty-https.xml
配置好之后,使用```java -jar start.jar```命令既可以同时启动监听HTTP端口与HTTPS端口。

Embeded Jetty

Configuration

可以在war的WEB-INF/jetty-web.xml文件中设置该Web Application的相关配置。

你可能感兴趣的:(java,spring,servlet,jetty)