Nginxの設定ファイルにディレクトリをプレフィックスとして追加できますか?

Nginxの設定ファイルにディレクトリをプレフィックスとして追加できますか?

私は簡単なDebianイメージを使用する開発環境を持っており、ステージング環境としてJetware EC2に最適化されたDebianイメージも使用しています。

Jetwareファイルシステムは以下にインストールされるため、/jetnginx.confとvhostファイルの間にいくつかの変更があります。たとえば、次のようになります。

pid /run/nginx/nginx.pid; そして pid /jet/run/nginx/nginx.pid;

またはinclude /jet/etc/nginx/mime.types;vs include /jet/etc/nginx/mime.types;

お持ちですか?サーバールートディレクトリファイル間の変更を最小限に抑えるためにnginx.conf設定に追加できるディレクティブの種類はありますか?

ベストアンサー1

方法(ファイルの上部で「$filesystem_root_dir」変数を起動し、各構成に値を割り当てる方法)は次のとおりです。

  • 許可されていません(致命的なエラーが発生しますnginx: [emerg] "set" directive is not allowed here in /etc/nginx/nginx.conf:1:)
  • Nginxチームは次のように落胆しました。
Variables should not be used as template macros. Variables are evaluated in the run-time during the processing of each request, so they are rather costly compared to plain static configuration. Using variables to store static strings is also a bad idea. Instead, a macro expansion and "include" directives should be used to generate configs more easily and it can be done with the external tools, e.g. sed + make or any other common template mechanism. 

http://nginx.org/en/docs/faq/variables_in_config.html

テンプレートジェネレータの使用を検討しましたが、コストが利点よりはるかに大きいため、ファイルを少し異なる状態に保ちたいと思いました。

おすすめ記事