次のようなルートで nginx.conf ファイルを作成する必要があります: /assets - 静的ファイル、/akka - hello-world akka webapp 用、/* - デフォルト ページ。私の default.conf ファイルは次のようになります。
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
upstream hello-akka{
server localhost:9000;
}
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /akka {
proxy_pass http://hello-akka;
}
location /assets {
root /var/www;
}
}
}
nginx サービスを再起動するたびに、次のエラー メッセージが表示されます。
nginx: [emerg] "worker_processes" directive is not allowed here in /etc/nginx/conf.d/default.conf:2
nginx: configuration file /etc/nginx/nginx.conf test failed
ファイル自体の構造を確認しましたが、何が間違っているのかわかりません。この行を削除しても、pid、イベントなどの他の行では同じ「ディレクティブは許可されていません」というエラーが発生します。どうすればこのようなエラーを修正できますか?
ベストアンサー1
/etc/nginx/nginx.conf
その指令を の代わりに の先頭に配置します/etc/nginx/conf.d/default.conf
。
ディレクティブworker_processes
は構成の最上位レベルでのみ有効です。
今ではデフォルトで に付属しています/etc/nginx/nginx.conf
。