Back to lessons

Hosting Operations

Show Nginx Include Lines

You need to see which files the main Nginx config is expected to include.

Command

grep -RInE '^[[:space:]]*include[[:space:]]' fixtures/nginx/nginx.conf fixtures/nginx/conf.d fixtures/nginx/sites-enabled

What changed

Nothing changes. The command searches for include directives.

Danger

safe

When to use it

Use when an edited config file appears to be ignored.

When not to use it

Do not assume every include glob matches files; inspect the target path when output looks suspicious.

Undo or recovery

No undo needed because this command is read-only.

Expected output

Include directives with config paths and line numbers.

demo script

Disposable terminal steps

  1. cat fixtures/nginx/nginx.conf
  2. grep -RInE '^[[:space:]]*include[[:space:]]' fixtures/nginx/nginx.conf fixtures/nginx/conf.d fixtures/nginx/sites-enabled
  3. find fixtures/nginx -maxdepth 3 -type f | sort

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ cat fixtures/nginx/nginx.conf
events {}
http {
  include conf.d/*.conf;
  include sites-enabled/*;
}
::exit-code::0
$ grep -RInE '^[[:space:]]*include[[:space:]]' fixtures/nginx/nginx.conf fixtures/nginx/conf.d fixtures/nginx/sites-enabled
fixtures/nginx/nginx.conf:3:  include conf.d/*.conf;
fixtures/nginx/nginx.conf:4:  include sites-enabled/*;
::exit-code::0
$ find fixtures/nginx -maxdepth 3 -type f | sort
fixtures/nginx/conf.d/admin.conf
fixtures/nginx/nginx.conf
fixtures/nginx/sites-enabled/example.conf
::exit-code::0

YouTube Short

Is that config included?

Editing a file does not matter if Nginx never includes it. Search the include chain before changing more config.

LinkedIn hook

The config was valid; it just was not included.

Question: What is your quickest way to prove a config file is in the include path?

experiments

A/B tests to run

Metric: completion_rate

A: Not included.

B: Trace includes before editing.