Hosting Operations
Read-only, can be slowFind Which Nginx Config Owns a Domain
You need to find which Nginx config contains a domain's `server_name`.
Command
grep -R "server_name" /etc/nginx/sites-enabled/
Before you run this
System impact: Read-only. Can create load on large logs, directories, filesystems, or process tables.
When not to use it: Do not assume the first match controls HTTPS if separate SSL configs exist.
Expected output
Config paths with matching `server_name` lines.
System impact
Read-only, can be slow. Nothing changes. The command searches enabled server names.
May require elevated permissions on protected paths or service-owned files.
Scope this to the smallest useful path or service on busy systems.
Recovery / rollback: no state is changed.
When to use it
Use this when a domain routes to the wrong site.
When not to use it
Do not assume the first match controls HTTPS if separate SSL configs exist.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ grep -R "server_name" /etc/nginx/sites-enabled/
/etc/nginx/sites-enabled/example.com: server_name example.com example.com;
$ grep -R "root" /etc/nginx/sites-enabled/
/etc/nginx/sites-enabled/example.com: root /srv/www/example.com/current;
$ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
grep -R "server_name" /etc/nginx/sites-enabled/grep -R "root" /etc/nginx/sites-enabled/nginx -t
next steps
Related commands
Find the Nginx Default Server
The wrong site answered because it was the fallback.
grep -RIn 'default_server' fixtures/nginx/conf.d fixtures/nginx/sites-enabled
List Nginx Listen Directives
The site was configured, but the port was not.
grep -RInE '^[[:space:]]*listen[[:space:]]' fixtures/nginx/conf.d fixtures/nginx/sites-enabled
Map Nginx Roots and Aliases
The URL was right. The filesystem path was not.
grep -RInE '^[[:space:]]*(root|alias)[[:space:]]' fixtures/nginx/conf.d fixtures/nginx/sites-enabled
Show Nginx Include Lines
The config was valid; it just was not included.
grep -RInE '^[[:space:]]*include[[:space:]]' fixtures/nginx/nginx.conf fixtures/nginx/conf.d fixtures/nginx/sites-enabled
Map Nginx Proxy Targets
Nginx was healthy. It was proxying to the wrong place.
grep -RInE '^[[:space:]]*proxy_pass[[:space:]]' fixtures/nginx/conf.d fixtures/nginx/sites-enabled
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.