Jetty的http2模組

jackieathome發表於2024-03-10

啟用http2模組,執行如下命令:

java -jar $JETTY_HOME/start.jar --add-modules=http2

命令的輸出,如下:

INFO  : http2           initialized in ${jetty.base}/start.d/http2.ini
INFO  : Base directory was modified

http2模組的配置檔案$JETTY_BASE/start.d/http2.ini,內容如下:

# ---------------------------------------
# Module: http2
# Enables the support for the secure HTTP/2 protocol.
# ---------------------------------------
--modules=http2

## Specifies the maximum number of concurrent requests per session.
# jetty.http2.maxConcurrentStreams=128

## Specifies the initial stream receive window (client to server) in bytes.
# jetty.http2.initialStreamRecvWindow=524288

## Specifies the initial session receive window (client to server) in bytes.
# jetty.http2.initialSessionRecvWindow=1048576

## Specifies the maximum number of keys in all SETTINGS frames received by a session.
# jetty.http2.maxSettingsKeys=64

## Specifies the maximum number of bad frames and pings per second,
## after which a session is closed to avoid denial of service attacks.
# jetty.http2.rateControl.maxEventsPerSecond=50

各引數的說明,如下:

  • jetty.http2.maxConcurrentStreams
    單個會話中允許並行的HTTP請求數量的上限值,預設值為128
  • jetty.http2.initialStreamRecvWindow
    流接收資料的視窗的初始容量,單位:位元組,預設值為524288
  • jetty.http2.initialSessionRecvWindow
    會話接收資料的視窗的初始容量,單位:位元組,預設值為1232896
  • jetty.http2.maxSettingsKeys
    在會話的SETTINGS幀中允許接收的key的數量,預設值為64
  • jetty.http2.rateControl.maxEventsPerSecond
    每秒允許出現的壞幀及ping的數量的上限,超出上限,則判定會話失效,以此來規避潛在的DoS攻擊。
    預設值為50

HTTP2要求使用安全通道傳輸資料,http2c模組基於非安全通道提供HTTP2協議的服務。
啟用http2c模組,執行如下命令:

java -jar $JETTY_HOME/start.jar --add-modules=http2c

命令的輸出,如下:

INFO  : http2c          initialized in ${jetty.base}/start.d/http2c.ini
INFO  : Base directory was modified

http2c模組的配置檔案$JETTY_BASE/start.d/http2c.ini,內容如下:

# ---------------------------------------
# Module: http2c
# Enables the support for the clear-text HTTP/2 protocol.
# ---------------------------------------
--modules=http2c

## Specifies the maximum number of concurrent requests per session.
# jetty.http2c.maxConcurrentStreams=128

## Specifies the initial stream receive window (client to server) in bytes.
# jetty.http2c.initialStreamRecvWindow=524288

## Specifies the initial session receive window (client to server) in bytes.
# jetty.http2c.initialSessionRecvWindow=1232896

## Specifies the maximum number of keys in all SETTINGS frames received by a session.
# jetty.http2c.maxSettingsKeys=64

## Specifies the maximum number of bad frames and pings per second,
## after which a session is closed to avoid denial of service attacks.
# jetty.http2c.rateControl.maxEventsPerSecond=50

各引數的說明,如下:

  • jetty.http2c.maxConcurrentStreams
    單個會話中允許並行的HTTP請求數量的上限值,預設值為128
  • jetty.http2c.initialStreamRecvWindow
    流接收資料的視窗的初始容量,單位:位元組,預設值為524288
  • jetty.http2c.initialSessionRecvWindow
    會話接收資料的視窗的初始容量,單位:位元組,預設值為1232896
  • jetty.http2c.maxSettingsKeys
    在會話的SETTINGS幀中允許接收的key的數量,預設值為64
  • jetty.http2c.rateControl.maxEventsPerSecond
    每秒允許出現的壞幀及ping的數量的上限,超出上限,則判定會話失效,以此來規避潛在的DoS攻擊。
    預設值為50

參考資料

  • Nginx變更HTTP2配置過程記錄
  • nginx配置域名啟用http2協議

相關文章