1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

nginxで、ちょっとしたセキュリティ対策(アップデート編-バージョン維持)

1
Posted at

前の記事

OCIのOracle LinuxでWebサーバ(nginx)を動かす(HTTPまで)

1.現在のバージョン確認

1.1.バージョン確認

バージョン確認
[opc@test-server ~]$ sudo nginx -v
nginx version: nginx/1.xx.x

xx.xがバージョン

1.2.設定のバックアップ

設定バックアップ
[opc@test-server ~]$ sudo cp -a /etc/nginx ~/nginx-backup-$(date +%Y%m%d)

2.nginxアップデート

2.1.nginxアップデート

アップデート

アップデート

[opc@test-server ~]$ sudo dnf upgrade nginx
Last metadata expiration check: 9:99:99 ago on Xxx 99 Xxx 2099 09:99:99 PM XXX.
Dependencies resolved.
================================================================================
 Package            Arch     Version                      Repository       Size
================================================================================
Upgrading:
 nginx              x86_64   2:1.XX.X-XX.X.X.el9_9.1      ol9_appstream    XX k
 nginx-core         x86_64   2:1.XX.X-XX.X.X.el9_9.1      ol9_appstream   XXX k
 nginx-filesystem   noarch   2:1.XX.X-XX.X.X.el9_9.1      ol9_appstream    XX k

Transaction Summary
================================================================================
Upgrade  3 Packages

Total download size: XXX k
Is this ok [y/N]: y
Downloading Packages:
(1/3): nginx-1.XX.X-XX.X.X.el9_9.1.x86_64.rpm   248 kB/s | XXX kB     00:00
(2/3): nginx-filesystem-1.XX.X-XX.X.X.el9_9.1.n  56 kB/s |  XX kB     00:00
(3/3): nginx-core-1.XX.X-XX.X.X.el9_9.1.x86_64. 2.2 MB/s | XXX kB     00:00
--------------------------------------------------------------------------------
Total                                           2.0 MB/s | 657 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Running scriptlet: nginx-filesystem-2:1.XX.X-XX.X.X.el9_9.1.noarch        1/6
  Upgrading        : nginx-filesystem-2:1.XX.X-XX.X.X.el9_9.1.noarch        1/6
  Upgrading        : nginx-core-2:1.XX.X-XX.X.X.el9_9.1.x86_64              2/6
  Upgrading        : nginx-2:1.XX.X-XX.X.X.el9_9.1.x86_64                   3/6
  Running scriptlet: nginx-2:1.XX.X-XX.X.X.el9_9.1.x86_64                   3/6
  Running scriptlet: nginx-2:1.XX.X-XX.X.X.el9_8.3.x86_64                   4/6
  Cleanup          : nginx-2:1.XX.X-XX.X.X.el9_8.3.x86_64                   4/6
  Running scriptlet: nginx-2:1.XX.X-XX.X.X.el9_8.3.x86_64                   4/6
  Cleanup          : nginx-core-2:1.XX.X-XX.X.X.el9_8.3.x86_64              5/6
  Cleanup          : nginx-filesystem-2:1.XX.X-XX.X.X.el9_8.3.noarch        6/6
  Running scriptlet: nginx-filesystem-2:1.XX.X-XX.X.X.el9_8.3.noarch        6/6
  Verifying        : nginx-2:1.XX.X-XX.X.X.el9_9.1.x86_64                   1/6
  Verifying        : nginx-2:1.XX.X-XX.X.X.el9_8.3.x86_64                   2/6
  Verifying        : nginx-core-2:1.XX.X-XX.X.X.el9_9.1.x86_64              3/6
  Verifying        : nginx-core-2:1.XX.X-XX.X.X.el9_8.3.x86_64              4/6
  Verifying        : nginx-filesystem-2:1.XX.X-XX.X.X.el9_9.1.noarch        5/6
  Verifying        : nginx-filesystem-2:1.XX.X-XX.X.X.el9_8.3.noarch        6/6
[opc@test-server ~]$

2.2.再起動(restart)

再起動
[opc@test-server ~]$ sudo systemctl restart nginx

reloadとrestartの違い

reload

マスタープロセスを維持したまま新しいワーカープロセスを起動します。
動いているワーカープロセスが処理を終えてから終了するため、通信を中断せず設定を反映できます。
その代わり、マスタープロセスが動いたままなので、バージョンアップが反映されません。

restart

Nginxプロセスを一度停止して再起動します。
マスタープロセスを停止させるので、バージョンアップが反映されます。
マスタープロセスが停止するため、処理が途切れる(=通信が途切れる)可能性があります。そのため、ダウンタイムが発生する可能性があります。

最後に

記事の内容はCC BY-SA 4.0(著作者の情報とCCライセンス継承はお願いします。商用利用・改変・再配布は問題なし)です。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?