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?

Amazon Linux 2023 に Nginx をインストールして Dify ページを表示する

Posted at

Amazon Linux 2023 (AL2023) で Web サーバーを立てて、Dify で作ったチャットボットページを表示する手順をまとめました。
以前の Amazon Linux 2 で使えた amazon-linux-extras は AL2023 には存在しません。そのため、パッケージはすべて dnf から直接インストールします。


1. Nginx のインストール

sudo dnf install -y nginx

インストール後、サービスを起動します。

sudo systemctl enable nginx
sudo systemctl start nginx

ブラウザで http://<EC2のPublicIP>/ にアクセスすると、最初は「Welcome to nginx!」が表示されれば成功です。


2. 確認用ページの作成

デフォルトのドキュメントルートは /usr/share/nginx/html です。
まずは動作確認用に簡単なページを作ります。

sudo bash -c 'echo "Hello from Nginx on AL2023" > /usr/share/nginx/html/index.html'

これでアクセスすると、ブラウザに Hello from Nginx on AL2023 と表示されます。


3. Dify チャットボットを埋め込む

次に、Dify が提供する iframe を HTML に埋め込みます。

sudo tee /usr/share/nginx/html/index.html >/dev/null <<'HTML'
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Dify Chatbot</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <style>html,body{height:100%;margin:0}</style>
</head>
<body>
  <iframe
    src=<difyのアプリのアドレス>
    style="width: 100%; height: 100%; min-height: 700px; border:0"
    frameborder="0"
    allow="microphone">
  </iframe>
</body>
</html>
HTML

4. 表示確認

ブラウザで http://<EC2のPublicIP>/ を再読み込みすると、Dify のチャットボットが表示されます。
もしキャッシュが残っている場合は Ctrl+F5 で強制再読み込みしてください。


まとめ

  • AL2023 には amazon-linux-extras がなく、dnf install で直接インストールする
  • デフォルトのルートは /usr/share/nginx/html/
  • index.html を置き換えれば Dify の iframe ページも簡単に表示できる

これで EC2 上の Nginx を使って、Dify で作ったチャットボットを公開できました。

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?