OCI Linuxとブートストラップでファイアウォールポートを開く (2020/10/23)

 OCI Linuxとブートストラップでファイアウォールポートを開く (2020/10/23)

https://www.thatfinnishguy.blog/2020/10/23/oci-linux-and-opening-firewall-ports-with-bootstrap/
これは短い投稿ですが、私が悩んでいたことです。

OCI Linux 7.8インスタンスを起動しているときに、ポート80をオープンにしたいと思い、
コンピュートインスタンスを作成するときにadvancedセクションにあるcloud-initの部分を使用していました。

最初はブートストラップの設定でこのようにしていました。

#!/bin/bash
sudo yum install httpd wget php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo -y
sudo systemctl enable httpd
sudo systemctl restart httpd
sudo firewall-cmd --add-service=http
sudo firewall-cmd --add-service=https
sudo firewall-cmd --reload




しかし、何をやっても yum コマンドの後は何も実行されませんでした。
パッケージのインストールが終わった後、cloud-initの/var/log/messagesに以下の行があることに気がつきました。

Oct 23 16:54:07 instance-20201023-1246 cloud-init: ERROR:dbus.proxies:Introspect error on :1.4:/org/fedoraproject/FirewallD1: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

検索してみると、SELinuxがファイアウォールの自動設定を妨げる場合があると書いてある以下のメモを見つけました
SELinuxを無効にするか、無効にしたくない場合は上記のメモの手順に従ってください。

ブートストラップスクリプトを以下のように変更しました。

#!/bin/bash
yum install httpd wget php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo -y
systemctl stop firewalld
firewall-offline-cmd --add-service=https
firewall-offline-cmd --add-service=http
systemctl start firewalld
systemctl enable httpd.service
systemctl restart httpd.service


そして、これでOK! この修正後、問題なくウェブサーバにアクセスできました。

* 最初は sudo firewall-cmd -permanent -add-service=http を使用していましたが、
再起動後にのみ再生されるように、実際のコマンドはパーマネントオプションなしでなければならないことが強調表示されました!

コメント

このブログの人気の投稿

Oracle RACによるメンテナンスのためのドレインとアプリケーション・コンティニュイティの仕組み (2023/11/01)

Oracle Cloud Infrastructure Secure Desktopsを発表: デスクトップ仮想化のためのOracleのクラウドネイティブ・サービス (2023/06/28)

新しいOracle Container Engine for Kubernetesの機能強化により、大規模なKubernetesがさらに簡単になりました (2023/03/20)