Web / NGINX Interview questions
What are server blocks in NGINX?
A server block is NGINX's equivalent of Apache's virtual host - it defines how requests for a particular domain, port, or IP should be handled.
server { listen 80; server_name example.com www.example.com; root /var/www/example; location / { try_files $uri $uri/ =404; } }
A single NGINX instance can hold many server blocks, each matched by the incoming Host header and listening port. This lets one machine host multiple independent websites or APIs, each with its own root directory, SSL certificate, and routing rules.
More Related questions...