啟用server
模組,執行如下命令:
java -jar $JETTY_HOME/start.jar --add-modules=server
命令的輸出,如下:
INFO : server initialized in ${jetty.base}/start.d/server.ini
INFO : Base directory was modified
檢視server
模組的配置檔案,執行如下命令:
cat $JETTY_BASE/start.d/server.ini
命令的輸出,如下:
# ---------------------------------------
# Module: server
# Enables and configures the Jetty server.
# This module does not enable any network protocol support.
# To enable a specific network protocol such as HTTP/1.1, you must enable the correspondent Jetty module.
# ---------------------------------------
--modules=server
### Common HTTP configuration
## Scheme to use to build URIs for secure redirects
# jetty.httpConfig.secureScheme=https
## Port to use to build URIs for secure redirects
# jetty.httpConfig.securePort=8443
## Response content buffer size (in bytes)
# jetty.httpConfig.outputBufferSize=32768
## Max response content write length that is buffered (in bytes)
# jetty.httpConfig.outputAggregationSize=8192
## If HTTP/1.x persistent connections should be enabled
# jetty.httpConfig.persistentConnectionsEnabled=true
## Max request headers size (in bytes)
# jetty.httpConfig.requestHeaderSize=8192
## Max response headers size (in bytes)
# jetty.httpConfig.responseHeaderSize=8192
## Whether to send the Server: header
# jetty.httpConfig.sendServerVersion=true
## Whether to send the Date: header
# jetty.httpConfig.sendDateHeader=false
## Max per-connection header cache size (in nodes)
# jetty.httpConfig.headerCacheSize=1024
## Whether, for requests with content, delay dispatch until some content has arrived
# jetty.httpConfig.delayDispatchUntilContent=true
## Maximum number of error dispatches to prevent looping
# jetty.httpConfig.maxErrorDispatches=10
## Relative Redirect Locations allowed
# jetty.httpConfig.relativeRedirectAllowed=true
## Whether to use direct ByteBuffers for reading or writing
# jetty.httpConfig.useInputDirectByteBuffers=true
# jetty.httpConfig.useOutputDirectByteBuffers=true
## HTTP Compliance: RFC7230, RFC7230_LEGACY, RFC2616, RFC2616_LEGACY, LEGACY
# jetty.httpConfig.compliance=RFC7230
## URI Compliance: DEFAULT, LEGACY, RFC3986, RFC3986_UNAMBIGUOUS, UNSAFE
# jetty.httpConfig.uriCompliance=DEFAULT
## Cookie compliance mode for parsing request Cookie headers: RFC6265_STRICT, RFC6265, RFC6265_LEGACY, RFC2965, RFC2965_LEGACY
# jetty.httpConfig.requestCookieCompliance=RFC6265
## Cookie compliance mode for generating response Set-Cookie: RFC2965, RFC6265
# jetty.httpConfig.responseCookieCompliance=RFC6265
### Server configuration
## Whether ctrl+c on the console gracefully stops the Jetty server
# jetty.server.stopAtShutdown=true
## Timeout in ms to apply when stopping the server gracefully
# jetty.server.stopTimeout=5000
## Dump the state of the Jetty server, components, and webapps after startup
# jetty.server.dumpAfterStart=false
## The temporary directory used by the Jetty server and as a root for its contexts
# jetty.server.tempDirectory=
## Dump the state of the Jetty server, components, and webapps before shutdown
# jetty.server.dumpBeforeStop=false
### Server Scheduler Configuration
## The scheduler thread name, defaults to "Scheduler-{hashCode()}" if blank.
# jetty.scheduler.name=
## Whether the server scheduler threads are daemon.
# jetty.scheduler.daemon=false
## The number of server scheduler threads.
# jetty.scheduler.threads=1
## Whether the handlers of the ContextHandlerCollection can be updated once the server is started
## If set to false, then eeN-deploy module jetty.deploy.scanInterval should also be set to 0.
# jetty.server.contexts.dynamic=true
## Should the DefaultHandler serve the jetty favicon.ico from the root.
# jetty.server.default.serveFavIcon=true
## Should the DefaultHandler show a list of known contexts in a root 404 response.
# jetty.server.default.showContexts=true
各引數的說明,如下:
-
HTTP協議的常見引數
-
jetty.httpConfig.secureScheme
重定向時,安全通道使用的協議。預設值為https
。 -
jetty.httpConfig.securePort
重定向時,安全通道的監聽埠。預設值為8443
。 -
jetty.httpConfig.outputBufferSize
響應訊息的緩衝區容量,單位:位元組。預設值為32768
。 -
jetty.httpConfig.outputAggregationSize
返回響應資料時,單次寫操作的最大資料量,單位:位元組。預設值為8192
。 -
jetty.httpConfig.persistentConnectionsEnabled
是否啟用HTTP/1.x
中定義的HTTP連結保持特性。 -
jetty.httpConfig.requestHeaderSize
HTTP請求訊息中頭部的最大長度,單位:位元組。預設值為8192
。 -
jetty.httpConfig.responseHeaderSize
HTTP響應訊息中頭部的最大長度,單位:位元組。預設值為8192
。 -
jetty.httpConfig.sendServerVersion
是否在HTTP響應訊息中增加頭部Server
。預設值為true
。
如下為樣例:HTTP/1.1 200 OK Content-Length: 0 Server: Jetty(12.0.6)
基於業務安全的考慮,透過不建議開啟,即修改為
false
。 -
jetty.httpConfig.sendDateHeader
響應訊息中,是否傳送HTTP頭部Date
欄位。預設值為false
。 -
jetty.httpConfig.headerCacheSize
處理HTTP頭部時的緩衝資料的大小,單位:位元組,預設值為1024
。 -
jetty.httpConfig.delayDispatchUntilContent
收到訊息體之後再分發請求物件,預設值為true
。 -
jetty.httpConfig.maxErrorDispatches
錯誤場景下分發次數的最大值,避免迴圈處理,預設值為10
。 -
jetty.httpConfig.relativeRedirectAllowed
是否允許重定向操作,預設值為true
。 -
jetty.httpConfig.useInputDirectByteBuffers
預設值為true
。 -
jetty.httpConfig.useOutputDirectByteBuffers
預設值為true
。
-
-
jetty.httpConfig.compliance
HTTP協議規範相容性的選項,可選值如下:RFC7230
RFC7230_LEGACY
RFC2616
RFC2616_LEGACY
LEGACY
-
jetty.httpConfig.uriCompliance
URI規範的相容性的選項,可選值如下:DEFAULT
LEGACY
RFC3986
RFC3986_UNAMBIGUOUS
UNSAFE
-
jetty.httpConfig.requestCookieCompliance
Cookie規範的相容性的選項,可選值如下:RFC6265_STRICT
RFC6265
RFC6265_LEGACY
RFC2965
RFC2965_LEGACY
-
jetty.httpConfig.responseCookieCompliance
Cookie規範的相容性的選項,可選值如下:RFC2965
RFC6265
-
jetty.server.stopAtShutdown
Jetty程序收到控制檯傳送的Ctrl+C時,優雅退出。預設值為true
。 -
jetty.server.stopTimeout
優雅退出時的超時值,單位:毫秒。預設值為5000
,即5
秒。 -
jetty.server.dumpAfterStart
啟動結束後,輸出Jetty程序的狀態,元件等資訊。 -
jetty.server.tempDirectory
Jetty程序執行期使用的臨時目錄。 -
jetty.server.dumpBeforeStop
Jetty程序退出前,輸出Jetty程序的狀態,元件等資訊。 -
jetty.scheduler.name
-
jetty.scheduler.daemon
-
jetty.scheduler.threads
-
jetty.server.contexts.dynamic
-
jetty.server.default.serveFavIcon
-
jetty.server.default.showContexts