jboss eap 7_使用JBoss EAP 7的HTTP / 2
jboss eap 7
就在幾天前,新的JBoss EAP 7 ALPHA版本已經發布。 而且我已經寫過博客,介紹如何開始使用它 。 一個非常有趣的部分是HTTP / 2支持,它已作為技術預覽添加。 它由新的Web服務器Untertow提供。 HTTP / 2通過壓縮頭并在同一TCP連接上多路復用多個流來減少延遲。 它還支持服務器在請求資源之前將資源推送到客戶端的功能,從而可以更快地加載頁面。
技術預覽組件
關于技術預覽實際含義的簡短說明。 JBoss EAP中的某些功能是作為技術預覽提供的。 這意味著,盡管這些組件已包含在JBoss EAP中,但是它們在功能上并不完整,不適合生產使用。 因此,它們在開發中得到支持,但不推薦或不支持用于生產用途。 但是它們可以幫助我們獲得更廣泛的曝光和反饋。 因此,如果您鼓勵某些無法正常工作的事情,或者對此功能的未來方向有想法,請隨時與我們聯系。
紅帽公司打算在將來的版本中完全支持技術預覽功能。
準備您的EAP安裝
應用層協議協商(ALPN)是SSL協議的擴展,有助于加快HTTPS連接的速度。 它是與HTTP / 2一起定義的,它使用ALPN創建HTTPS連接。 由于大多數瀏覽器僅通過HTTPS實現HTTP / 2,因此OpenJDK在sun.security.ssl軟件包中實現了SSL。 Java 7和Java 8中的當前實現不支持ALPN。 使用Java 9,(希望)將對ALPN( JEP 244 )提供本機支持。 EAP要求您使用Java8。由于缺少密碼,因此根本無法在Java 7上運行HTTP / 2示例。
由于HTTP / 2也是Java EE8的目標,因此有望在Java 9發行之后的將來的Java SE 8更新中使用它。
為了解決Java 8上的這一限制,我們需要添加一個庫,該庫為JVM的啟動類路徑提供ALPN支持。 所需的jar文件的版本與使用中的JVM版本相關,因此必須確保為JVM使用正確的版本。 Jetty為Java提供了一個ALPN實現。 請訪問碼頭網站,找到適合您的JDK的版本 。 在此示例中,我使用的JDK 1.8.0u60需要ALPN版本:“ 8.1.5.v20150921”。
將工作文件夾切換到JBOSS_HOME并將alpn庫下載到/ bin文件夾。
curl http://central.maven.org/maven2/org/mortbay/jetty/alpn/alpn-boot/8.1.5.v20150921/alpn-boot-8.1.5.v20150921.jar >bin/alpn-boot-8.1.5.v20150921.jar現在需要將該庫添加到服務器的bootclasspath中。 將以下行添加到獨立配置文件中
//standalone.conf on Linux JAVA_OPTS="$JAVA_OPTS ?-Xbootclasspath/p:$JBOSS_HOME/bin/alpn-boot-8.1.5.v20150921.jar"//standalone.conf.bat on Windows set "JAVA_OPTS=%JAVA_OPTS% -Xbootclasspath/p:%JBOSS_HOME%/bin/alpn-boot-8.1.5.v20150921.jar"下一步是為https連接器安裝證書。 出于測試目的,您可以從Undertow測試套件中下載。 在我的舊博客中了解如何生成和運行自己的SSL證書 。
curl https://raw.githubusercontent.com/undertow-io/undertow/master/core/src/test/resources/server.keystore >standalone/configuration/server.keystore curl https://raw.githubusercontent.com/undertow-io/undertow/master/core/src/test/resources/server.truststore >standalone/configuration/server.truststore完成后,請啟動服務器并通過命令行工具添加https連接器(連接到正在運行的服務器并發出以下突出顯示的命令):
$>jboss-cli.bat|shYou are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.[disconnected /] connect[standalone@localhost:9990 /] /core-service=management/security-realm=https:add(){"outcome" => "success"}[standalone@localhost:9990 /] ?/core-service=management/security-realm=https/authentication=truststore:add(keystore-path=server.truststore, keystore-password=password, keystore-relative-to=jboss.server.config.dir){"outcome" => "success","response-headers" => {"operation-requires-reload" => true,"process-state" => "reload-required"} }[standalone@localhost:9990 /] /core-service=management/security-realm=https/server-identity=ssl:add(keystore-path=server.keystore, keystore-password=password, keystore-relative-to=jboss.server.config.dir){"outcome" => "success","response-headers" => {"operation-requires-reload" => true,"process-state" => "reload-required"} }[standalone@localhost:9990 /] /subsystem=undertow/server=default-server/https-listener=https:add(socket-binding=https, security-realm=https, enable-http2=true){"outcome" => "success","response-headers" => {"process-state" => "reload-required"} } [standalone@localhost:9990 /]關閉并重新啟動EAP實例。
測試連接
當服務器再次啟動時,將瀏覽器指向https:// localhost:8443。 單擊有關自簽名證書的安全警告后,您會看到正常的EAP 7歡迎頁面。
但是,如何確定該連接實際上是使用HTTP / 2? 您可以通過多種方式執行此操作。 如果您使用的是Chrome,則可以在瀏覽器欄中輸入“ chrome:// net-internals”,然后在下拉菜單中選擇“ HTTP / 2”。 如果您重新加載EAP主頁并返回到chrome網絡頁面,則可以看到帶有所有標頭和信息的HTTP / 2會話。
另一個選擇是使用一些JavaScript并將其部署到您的應用程序中:
<p style="font-size: 125%;">You are currently connected using the protocol: <b style='color: darkred;' id="transport">checking...</b>.</p> <p id="summary" /> <script>var url = "/";var xhr = new XMLHttpRequest();xhr.onreadystatechange = function(e) {if (this.readyState === 4) {var transport = this.status == 200 ? xhr.getResponseHeader("X-Undertow-Transport") : null;transport = transport == null ? "unknown" : transport;document.getElementById("transport").innerHTML = transport;var summary = "No HTTP/2 Support!";if (transport.indexOf("h2") == 0) {summary = "Congratulations! Your client is using HTTP/2.";}document.getElementById("summary").innerHTML = summary;}}xhr.open('HEAD', url, true);xhr.send(); </script> 恭喜你! 您剛剛將EAP安裝升級到HTTP / 2! 不要忘記提供反饋并了解有關JBoss EAP 7的更多信息:并且請記住:與任何Alpha版本一樣,請預見問題。 如果發現任何問題,請在
相應的JIRA 。
- Java EE 7功能快速入門( ZIP下載 )
- 產品資料
- 入門指南
翻譯自: https://www.javacodegeeks.com/2015/11/http2-with-jboss-eap-7.html
jboss eap 7
總結
以上是生活随笔為你收集整理的jboss eap 7_使用JBoss EAP 7的HTTP / 2的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: xbox灵马快捷键(电脑Xbox快捷键)
- 下一篇: 电脑设置远程控制的方法如何让电脑远程