HTTPS Configurationを設定し、HTTPからHTTPSへのリダイレクトを設定することができます。この2つの操作は、以下に示すいくつかのコマンドを実行するだけで、簡単に行うことができます(これらのコマンドを実行する際には、サーバーが起動している必要があることに注意してください)。コマンドはすぐに使用できます。path=https.keystorecredential-reference={clear-text="dvserver"}の2つの要素をローカルシステムに合わせてカスタマイズするだけです。

HTTPS Configuration

  1. 自己署名証明書を作成します:
    1. 以下のコマンドを適応して実行してください:

      ./dvserver/JDK/bin/keytool -genkey -alias wildfly -keyalg RSA -keystore ./dvserver/standalone/configuration/https.keystore
    2. システムからプロンプトが表示されたら、パスワードを設定します。
  2. 以下のコマンドを実行して、elytronサブシステムを適応させます(path=https.keystorecredential-reference={clear-text="dvserver"}も忘れずにカスタマイズしてください):

    CALL SYSADMIN.executeCli(script => '/subsystem=elytron/key-store=httpsKeyStore:add(path=https.keystore,relative-to=jboss.server.config.dir, credential-reference={clear-text="dvserver"},type=JKS)') ;;
     
    CALL SYSADMIN.executeCli(script => '/subsystem=elytron/key-manager=httpsKeyManager:add(key-store=httpsKeyStore,credential-reference={clear-text="dvserver"})') ;;
     
    CALL SYSADMIN.executeCli(script => '/subsystem=elytron/server-ssl-context=httpsSSLContext:add(key-manager=httpsKeyManager,protocols=["TLSv1.2"])') ;;
  3. 以下のコマンドを実行して、undertowサブシステムを適応させます:

    CALL SYSADMIN.executeCli(script => '/subsystem=undertow/server=default-server/https-listener=https:add(socket-binding=https, ssl-context="httpsSSLContext", enable-http2="true")') ;;


    これでHTTPS Configurationは終了です。通常のHTTPローカルホスト( http://localhost:8080 )に加え、HTTPSローカルホスト( https://localhost:8443/ )も利用できるようになりました。HTTPSリダイレクトを設定したい場合は、さらにもう1つのステップが必要です!

HTTP-to-HTTPS Redirect

HTTPからHTTPSへのリダイレクトを設定するには、以下のコマンドを実行します:

CALL SYSADMIN.executeCli(script => '/subsystem=undertow/configuration=filter/rewrite=http-to-https:add(redirect=true, target="https://%{LOCAL_SERVER_NAME}:${jboss.https.port:8443}%{REQUEST_URL}%{QUERY_STRING}")') ;;
 
CALL SYSADMIN.executeCli(script => '/subsystem=undertow/server=default-server/host=default-host/filter-ref=http-to-https:add(predicate="equals(%{SCHEME},http)")') ;;