0
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で、ちょっとしたセキュリティ対策(アップデート編-OS標準:バージョンアップ)

0
Posted at

前の記事

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

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

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

1.1.バージョン確認

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

xx.xがバージョン。
xxを上げます!

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 module list nginx
Last metadata expiration check: 9:99:99 ago on Xxx 99 Xxx 2099 99:99:99 XX XXX.
Oracle Linux 9 Application Stream Packages (x86_64)
Name             Stream           Profiles             Summary
nginx            1.XX             common [d]           nginx webserver
nginx            1.XX             common [d]           nginx webserver
nginx            1.XX             common [d]           nginx webserver
[opc@test-server ~]$

2.2.nginxを指定してアップデート

2.2.1.現バージョンをリセットする

現バージョンをリセットする

[opc@test-server ~]$ sudo dnf module reset nginx -y
Last metadata expiration check: 9:99:99 ago on Xxx 99 Xxx 2099 99:99:99 XX XXX.
Dependencies resolved.
Nothing to do.
Complete!
[opc@test-server ~]$

依存関係とかいろいろとリセット

2.2.2.新バージョンを適用する

現バージョンの適用

[opc@test-server ~]$ sudo dnf module enable nginx:1.XX -y
Last metadata expiration check: 9:99:99 ago on Xxx 99 Xxx 2099 99:99:99 XX XXX.
================================================================================
 Package           Architecture     Version             Repository         Size
================================================================================
Enabling module streams:
 nginx                              1.XX

Transaction Summary
================================================================================

Complete!
[opc@test-server ~]$

dnf module enable nginx:1.XX のXXに入れたいバージョン、24とか26とかを入れる

Enabling module streams:
で表示されるバージョンを確認する

2.2.3.新バージョンにアップデートする

新バージョンへのアップデート

[opc@test-server ~]$ sudo dnf module enable nginx:1.XX -y
Last metadata expiration check: 9:99:99 ago on Xxx 99 Xxx 2099 99:99:99 XX XXX.
================================================================================
 Package
     Arch   Version                                         Repository     Size
================================================================================
Upgrading:
 nginx
     x86_64 2:1.XX.X-XX.X.X.module+el9.9.0+91132+a75313dd.1 ol9_appstream  46 k
 nginx-core
     x86_64 2:1.XX.X-XX.X.X.module+el9.9.0+91132+a75313dd.1 ol9_appstream 688 k
 nginx-filesystem
     noarch 2:1.XX.X-XX.X.X.module+el9.9.0+91132+a75313dd.1 ol9_appstream  10 k
 nginx-mod-http-perl
     x86_64 2:1.XX.X-XX.X.X.module+el9.9.0+91132+a75313dd.1 ol9_appstream  36 k

Transaction Summary
================================================================================
Upgrade  4 Packages

Total download size: 781 k
Downloading Packages:
(1/4): nginx-1.XX.X-XX.X.X.module+el9.9.0+91132 999 kB/s |  99 kB     00:00
(2/4): nginx-filesystem-1.XX.X-XX.X.X.module+el  99 kB/s |  99 kB     00:00
(3/4): nginx-mod-http-perl-1.XX.X-XX.X.X.module 999 kB/s |  99 kB     00:00
(4/4): nginx-core-1.XX.X-XX.X.X.module+el9.9.0+ 999 MB/s | 999 kB     00:00
--------------------------------------------------------------------------------
Total                                           9.9 MB/s | 999 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.module+el9.9.0+9113   1/8
  Upgrading        : nginx-filesystem-2:1.XX.X-XX.X.X.module+el9.9.0+9113   1/8
  Upgrading        : nginx-core-2:1.XX.X-XX.X.X.module+el9.9.0+91132+a753   2/8
warning: /etc/nginx/nginx.conf created as /etc/nginx/nginx.conf.rpmnew

  Upgrading        : nginx-2:1.XX.X-XX.X.X.module+el9.9.0+91132+a75313dd.   3/8
  Running scriptlet: nginx-2:1.XX.X-XX.X.X.module+el9.9.0+91132+a75313dd.   3/8
  Upgrading        : nginx-mod-http-perl-2:1.XX.X-XX.X.X.module+el9.9.0+9   4/8
  Running scriptlet: nginx-mod-http-perl-2:1.XX.X-XX.X.X.module+el9.9.0+9   4/8
  Cleanup          : nginx-mod-http-perl-2:1.20.1-28.0.1.el9_8.3.x86_64     5/8
  Running scriptlet: nginx-2:1.XX.X-XX.X.X.el9_9.1.x86_64                   6/8
  Cleanup          : nginx-2:1.XX.X-XX.X.X.el9_9.1.x86_64                   6/8
  Running scriptlet: nginx-2:1.XX.X-XX.X.X.el9_9.1.x86_64                   6/8
  Cleanup          : nginx-core-2:1.XX.X-XX.X.X.el9_9.1.x86_64              7/8
  Cleanup          : nginx-filesystem-2:1.XX.X-XX.X.X.el9_9.1.noarch        8/8
  Running scriptlet: nginx-filesystem-2:1.XX.X-XX.X.X.el9_9.1.noarch        8/8
  Verifying        : nginx-2:1.XX.X-XX.X.X.module+el9.9.0+91132+a75313dd.   1/8
  Verifying        : nginx-2:1.XX.X-XX.X.X.el9_9.1.x86_64                   2/8
  Verifying        : nginx-core-2:1.XX.X-XX.X.X.module+el9.9.0+91132+a753   3/8
  Verifying        : nginx-core-2:1.XX.X-XX.X.X.el9_9.1.x86_64              4/8
  Verifying        : nginx-filesystem-2:1.XX.X-XX.X.X.module+el9.9.0+9113   5/8
  Verifying        : nginx-filesystem-2:1.XX.X-XX.X.X.el9_9.1.noarch        6/8
  Verifying        : nginx-mod-http-perl-2:1.XX.X-XX.X.X.module+el9.9.0+9   7/8
  Verifying        : nginx-mod-http-perl-2:1.xx.x-xx.x.x.el9_8.3.x86_64     8/8

Upgraded:
  nginx-2:1.XX.X-XX.X.X.module+el9.9.0+91132+x99999xx.1.x86_64
  nginx-core-2:1.XX.X-XX.X.X.module+el9.9.0+91132+x99999xx.1.x86_64
  nginx-filesystem-2:1.XX.X-XX.X.X.module+el9.9.0+91132+x99999xx.1.noarch
  nginx-mod-http-perl-2:1.XX.X-XX.X.X.module+el9.9.0+91132+x99999xx.1.x86_64
  
Complete!
[opc@test-server ~]$

2.3.再起動(restart)

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

reloadとrestartの違い

reload

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

restart

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

最後に

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

0
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
0
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?