proxy
NGINXでリバースプロキスを行い、Webサーバとアプリケーションを異なる複数のNGINXで動作させるnginxリバースプロキシ + 運用nginx + 検証nginxに切り替えます。また、サービスの再起動を行います。
Webサーバの違いについてはKUSANAGI Security EditionのWebサーバ構成を参照してください。
nginxリバースプロキシ、運用nginx、検証nginxのそれぞれで異なるNGINXのバージョンを指定できます。
検証nginxで検証期間が経過するまでに重大なエラー1が検知されなかった場合、自動的にnginxリバースプロキシと運用nginxのNGINXのバージョンを、検証nginxのNGINXのバージョンにアップグレードします。
また、検証nginxで検証期間中に重大なエラーが検知された場合、自動的に検証nginxを停止して、元のNGINXのバージョンのnginxリバースプロキシ + nginxの構成に切り替えます。
運用nginxと検証nginxは5:1の重み付けでロードバランスされます。
明示的に検証nginxにアクセスする場合は、HTTPリクエストのHTTPヘッダに X-Staging: on
を指定します。
使用例
kusanagi proxy --use nginx127 --staging latest
kusanagi proxy --nostaging
オプション
(オプション指定なし)
nginxリバースプロキシ + httpd を使用している場合は、nginxリバースプロキシ + 運用nginx + 検証nginx に切り替えます。
既にnginx を起動しているときは、nginxリバースプロキシ、運用nginx、検証nginxを再起動します。
リバースプロキシに使用するNGINX
[--use {installed | nginx129 | nginx128 | nginx127 | nginx126}]
デフォルト : installed
リバースプロキシに使用するNGINXのバージョンを指定します。それぞれ指定したときは以下のNGINXを起動します。
複数のNGINXのバージョンがインストールされている場合はいずれかの指定が必須です。
--useは、--reload、--test、--status と同時に指定できません。
- --use installed : 現在インストールされているNGINX
- --use nginx129 : NGINX 1.29
- --use nginx128 : NGINX 1.28
- --use nginx127 : NGINX 1.27
- --use nginx126 : NGINX 1.26
運用に使用するNGINX
[--production {nginx129 | nginx128 | nginx127 | nginx126 | latest}]
デフォルト : リバースプロキシに使用するNGINXと同じバージョン
運用に使用するNGINXのバージョンを指定します。それぞれ指定したときは以下のNGINXを起動します。
--productionは、--reload、--test、--status と同時に指定できません。
- --production nginx129 : NGINX 1.29
- --production nginx128 : NGINX 1.28
- --production nginx127 : NGINX 1.27
- --production nginx126 : NGINX 1.26
- --production latest : 最新版のNGINX
検証に使用するNGINX
[--staging {nginx129 | nginx128 | nginx127 | nginx126 | latest} | --nostaging | --no-staging]
デフォルト : 指定なし (検証nginxを変更しない)
検証に使用するNGINXのバージョンを指定します。それぞれ指定したときは以下のNGINXを起動します。
--nostaging もしくは --no-staging を指定すると、検証nginxを停止します。
--statging、--nostaging、--no-stagingのいずれの指定もない場合は、検証nginxに変更を行いません。既に検証nginxが起動していればそのNGINXのバージョンで起動したままとなり、検証nginxが停止していれば停止したままとなります。
--statging、--nostaging、--no-stagingは、--reload、--test、--status と同時に指定できません。
--statging、--nostaging、--no-stagingは同時に指定できません。
- --staging nginx129 : NGINX 1.29
- --staging nginx128 : NGINX 1.28
- --staging nginx127 : NGINX 1.27
- --staging nginx126 : NGINX 1.26
- --staging latest : 最新版のNGINX
検証期間
[--staging-days 検証日数]
デフォルト : 7日
検証nginxによる検証期間を日数で指定します。
--stagingと共に指定する場合にのみ効果があります。
設定の再読み込み
[--reload]
既存のセッションを切断することなく設定を再読込します。
--reloadは、--use、--production、--staging、--nostaging、--no-staging、--test、--status と同時に指定できません。
設定ファイルのチェック
[--test]
設定ファイルのチェックのみを行います。
--testは、--use、--production、--staging、--nostaging、--no-staging、--reload、--status と同時に指定できません。
ステータスの表示
[--stauts]
NGINXのステータスを表示します。
--statusは、--use、--production、--staging、--nostaging、--no-staging、--reload、--test と同時に指定できません。
実行例
# kusanagi proxy --use nginx127 --staging latest
nginx: the configuration file /etc/opt/kusanagi/nginx127/nginx-proxy.conf syntax is ok
nginx: configuration file /etc/opt/kusanagi/nginx127/nginx-proxy.conf test is successful
nginx: the configuration file /etc/opt/kusanagi/nginx127/nginx-production.conf syntax is ok
nginx: configuration file /etc/opt/kusanagi/nginx127/nginx-production.conf test is successful
nginx: the configuration file /etc/opt/kusanagi/nginx129/nginx-staging.conf syntax is ok
nginx: configuration file /etc/opt/kusanagi/nginx129/nginx-staging.conf test is successful
Created symlink /etc/systemd/system/multi-user.target.wants/nginx129@staging.service -> /usr/lib/systemd/system/nginx129@.service.
proxy completed.
- HTTP 500エラーが連続して2回以上発生する場合に重大なエラーと見なします。 ↩︎