What happens if no server block matches the request?
Nginx uses the first server block as the default. You can explicitly set a default with listen 80 default_server and return 444 to close connections with unknown Host headers, preventing access via IP address directly.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Nginx Server Blocks and Virtual Hosts Hosting Multiple Apps on One Server
Create a server block for each domain or subdomain. Each server block has a different server_name and proxy_pass or root. Enable all with symlinks to sites-enabled, test with nginx -t, and restart. Use certbot to get SSL for all domains.
A server block (also called virtual host) is a configuration section that defines how Nginx handles requests for a specific domain. It includes listen port, server_name, and location blocks for routing. Multiple server blocks allow hosting multiple sites on one server.
Use the upstream directive to define a pool of backend servers (e.g., upstream mybackend { server 127.0.0.1:3000; server 127.0.0.1:3001; }). Then use proxy_pass http://mybackend in the location block. Nginx distributes requests using round-robin by default.
Still have questions?
Browse all our FAQs or reach out to our support team
