LoginSignup
1
0

Oracle Linux 9 インスタンスへのnginx +Node jsアプリ作成  エラー 502 Bad Gateway

Last updated at Posted at 2023-11-16

背景

Node jsでサーバアプリケーション作成します。Nginxでリバースプロキシします。

Nginx install

  • インストール
$sudo yum update 
$sudo yum install -y nginx
  • nginx起動
$sudo systemctl start nginx
$sudo systemctl enable nginx
  • 状態チェック
$sudo systemctl status nginx

問題

https://xxxxx ウェブサイトアクセスするときに以下のエラー発生しました。

502 Bad Gateway
nginx/1.20.x

調査

curl -v http://localhost:3000

結果は、問題ない。

  • nginxのconfが正しいのか確認します。
    nginxの設定ファイルは/etc/nginx/nginx.confです。以下のコマンドで内容確認
sudo cat /etc/nginx/nginx.conf

これも問題ないです。

  • nginxのエラーログ確認
 sudo tail -f /var/log/nginx/error.log

以下のエラー発見しました。
connect() to 127.0.0.1:3000 failed (13: Permission denied) while connecting to upstream
問題はnginxがアクセスポート3000をアクセスできないのです。
そして以下のコマンドで解決できました。

sudo setsebool -P httpd_can_network_connect 1

 

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