nginxの導入中に出たnginx: configuration file /etc/nginx/nginx.conf test failedの解決方法がわからない
解決したいこと
ターミナルでnginx1を導入する際に設定ファイルを編集して再読み込みを行うと
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
と出てきます。
その原因をみていくと
2020/12/17 10:21:47 [warn] 26139#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:5
2020/12/17 10:21:47 [emerg] 26139#0: unexpected end of file, expecting ";" or "}" in /etc/nginx/conf.d/rails.conf:69
nginx: configuration file /etc/nginx/nginx.conf test failed
と出るので、設定ファイルの書き方がおかしいのかと思いました。
しかしここに、どこを探してもおかしいところを見つけることはできませんでした。
該当ファイルはこちらになります
sudo vim /etc/nginx/conf.d/rails.conf
upstream app_server {
# Unicornと連携させるための設定
server unix:/var/www/positi-bank/tmp/sockets/unicorn.sock;
}
# {}で囲った部分をブロックと呼ぶ。サーバの設定ができる
server {
# このプログラムが接続を受け付けるポート番号
listen 80;
# 接続を受け付けるリクエストURL ここに書いていないURLではアクセスできない
server_name 52.196.23.171;
# クライアントからアップロードされてくるファイルの容量の上限を2ギガに設定。デフォルトは1メガなので大きめにしておく
client_max_body_size 2g;
# 接続が来た際のrootディレクトリ
root /var/www/positi-bank/public;
# assetsファイル(CSSやJavaScriptのファイルなど)にアクセスが来た際に適用される設定
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
error_page 500 502 503 504 /500.html;
}
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
-- 挿入 --
自分で試したこと
指定された行数がそもそもないのでどこか記述を間違えているのかと思い何度も見返し、間違いのないよう見本となる記述をコピペしたりもしましたが変わりませんでした。
対策方法わかる方いらっしゃれば回答お願い致します。
0 likes