IBM の Java アプリケーションサーバーである WAS(Websphere Application Server) は標準設定のまま導入して使い始めると、9080 番ポート(http)や 9443 番ポート(https)でサーバーが起動します。これを一般的な 80 番や 443 番で起動させるための設定を紹介します。方法自体はいくつかあるのですが、ここで紹介するのは「とりあえずてっとり早くできる方法」です。 また今回は軽量版である WAS Liberty Core を対象として紹介します(フル機能版は次回)。具体的にはパブリッククラウドであるIBM Bluemix 内の WAS on Bluemix サービスの Liberty Core インスタンスを使って紹介します:


では実際に起動ポートを変更します。WAS Liberty Core の場合はアプリケーションサーバーの server.xml を編集することで変更できるので、まずはこのファイルを探します。

既にアプリケーションサーバーが起動している場合はウェブブラウザからも変更できます。 https://(ホスト名):9080/ にアクセスして、"Open Admin Console" をクリックします:
2017031601


認証が有効に設定されている場合は認証画面になります。正しいユーザー名とパスワードを入力して「送信」します:
2017031602


管理コンソールにアクセスできました。server.xml を編集するには "Server Config" を選択します:
2017031601


構成ファイルとして server.xml が表示されている(これしか表示されてない??)ので、server.xml をクリック:
2017031602


すると server.xml の編集画面に移動します。「ソース」タブで表示すると、XML テキストを直接編集することも可能です:
2017031603


なお、SSH 等でアプリケーションサーバーシステムに直接ログインできる場合であれば、server.xml は以下に存在しているので、このファイルを直接テキストエディタで編集しても構いません:
/opt/IBM/WebSphere/Profiles/Liberty/servers/server1/server.xml


以下の赤字部分4箇所を変更します。変更が完了したら保存(管理コンソールであれば右上のボタン)します:
<server description="Default Hypervisor Server">
  <!-- Simple application server, supporting servlets and jsps -->
  <featureManager>
    <feature>jsp-2.2</feature>
    <feature>adminCenter-1.0</feature>
  </featureManager>
<remoteFileAccess>
<writeDir>${server.config.dir}</writeDir>
</remoteFileAccess>
<virtualHost id="default_host" allowFromEndpointRef="defaultHttpEndpoint">
 <hostAlias>*:80</hostAlias>
 <hostAlias>*:443</hostAlias>
</virtualHost>
<!-- virtualHost id="external_host">
 <hostAlias>*:80</hostAlias>
 <hostAlias>*:443</hostAlias>
</virtualHost -->

  <quickStartSecurity userName="wsadmin" userPassword="{xor}am07ZzlubWg=" />
  <keyStore id="defaultKeyStore" password="{xor}am07ZzlubWg=" />
  <!-- disable automatic configuration and application updates, but leave mbean support enabled -->
  <config updateTrigger="mbean"/>
  <applicationMonitor updateTrigger="mbean" dropinsEnabled="true"/>
  <ssl id="defaultSSLConfig"
     sslProtocol="SSL_TLSv2"
     keyStoreRef="defaultKeyStore"
     clientAuthenticationSupported="true"/>

  <!-- open port 9080 for incoming http connections -->
  <httpEndpoint id="defaultHttpEndpoint"
                host="*"
                httpPort="80"
                httpsPort="443">
      <tcpOptions soReuseAddr="true"/>
  </httpEndpoint>
  <!-- httpEndpoint id="publicHttpEndpoint"
              host="*"
              httpPort="80"
              httpsPort="443">
      <tcpOptions soReuseAddr="true"/>
  </httpEndpoint -->
</server>


設定の変更そのものはこれだけです。後はアプリケーションサーバーを再起動・・・なのですが、OS が Linux の場合はもう1点注意が必要です。

Linux の場合、1024 番未満のポートはデフォルトでは root 権限がないと listen できません
。つまり上記の設定変更をしても再起動の際に root 以外のユーザー権限で再起動するとポートを listen できないのです。

特に IBM Bluemix 環境での場合、OS は RedHat で、その一般ユーザーである virtuser の権限で WAS は起動します。つまり上記の制約をまともに受けてしまうのでした。というわけで、WAS 再起動の際には注意が必要です。具体的にはまず root ユーザーに su(または sudo)し、root ユーザー権限でサーバーを止めて、再び起動、という手順が必要です:
$ sudo /bin/bash

# /opt/IBM/WebSphere/Liberty/bin/server stop server1

# /opt/IBM/WebSphere/Liberty/bin/server start server1

# exit

$


これで WAS Liberty Core が 80/443 番ポートで利用できるようになっているはずです:
2017031603