---
title: "Nginx: Web Server Fundamentals"
description: "Test your knowledge of Nginx configuration, reverse proxying, load balancing, and SSL/TLS termination."
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/quizzes/post/nginx-web-server-fundamentals-quiz
---

# Nginx: Web Server Fundamentals

Welcome to the Nginx Basics Quiz! Nginx is the Swiss Army knife of modern web infrastructure. Whether you are serving a simple static site, managing traffic for a massive cluster of microservices, or securing your apps with SSL, Nginx is likely at the center of your architecture. This quiz will test your ability to read, write, and troubleshoot Nginx configurations. Let's get started!

## Questions

### 1. What is the primary role of a "Reverse Proxy"?

- To encrypt client traffic for anonymous internet browsing
  - This describes a Forward Proxy or VPN, which masks the identity of the client to the internet.
- **To accept requests for a backend server and return the results** ✅
  - Correct! The client communicates with Nginx, which then retrieves data from an internal application server.
- To increase the physical clock speed of the server hardware
  - Software cannot change hardware clock speeds; performance gains come from efficient resource handling.
- To store and index site content in a relational database
  - Nginx is a web server and proxy; it does not function as a database engine like PostgreSQL or MySQL.

**Hint:** Think about who the client is talking to.

### 2. Which configuration block is used to define a virtual host in Nginx?

- The http {} block
  - The http block holds global settings for all traffic, but specific sites need their own sub-blocks.
- **The server {} block** ✅
  - Correct! The server block defines the configuration for a specific domain name, IP, or port.
- The location {} block
  - Location blocks exist inside server blocks to handle specific URL patterns or file paths.
- The upstream {} block
  - Upstream blocks define groups of backend servers but do not define the virtual host itself.

**Hint:** It defines the domain and port.

### 3. What does the "proxy_pass" directive do?

- It manages user authentication and password validation
  - Proxy_pass handles request routing, not user credentials or authentication logic.
- **It maps a URL path to a backend server or upstream group** ✅
  - Correct! This directive tells Nginx where to send the request after it has been received.
- It automates the rotation and deletion of old log files
  - Log management is handled by external tools like logrotate or specific Nginx log directives.
- It performs full disk encryption for the web server files
  - Disk encryption is an OS or hardware level task, not a function of Nginx proxy directives.

**Hint:** Sending the request forward.

### 4. Which load balancing algorithm is the default in Nginx?

- Least Connections
  - Least Connections routes traffic to the server with the fewest active requests; it must be set manually.
- **Round Robin** ✅
  - Correct! By default, Nginx distributes requests sequentially across all available servers in the upstream pool.
- IP Hash
  - IP Hash ensures a client always reaches the same backend server; it is not the default behavior.
- Weighted Random
  - Nginx does not utilize a random selection algorithm by default for load distribution.

**Hint:** One after another.

### 5. What is the purpose of the "upstream" block?

- To configure the external ISP network gateway
  - ISP settings are managed at the networking layer, not within Nginx configuration blocks.
- **To define a pool of backend servers for load balancing** ✅
  - Correct! This block groups multiple servers together so they can be referenced by a single name.
- To facilitate the upload of large binary files to the cloud
  - While Nginx facilitates the request, "upstream" specifically refers to server grouping, not file transfers.
- To restart the Nginx service after a configuration change
  - Service management is handled by the OS init system (like systemd) rather than a config block.

**Hint:** Grouping servers.

### 6. What does "SSL Termination" mean in the context of Nginx?

- Revoking an SSL certificate before its expiration date
  - Termination refers to the end-point of encryption, not the administrative revocation of a certificate.
- **Decrypting HTTPS traffic and sending HTTP to the backend** ✅
  - Correct! Nginx handles the heavy CPU task of decryption so the application server doesn’t have to.
- Removing private security keys from the physical server
  - Termination describes the flow of traffic, not the deletion of security assets or files.
- Blocking all incoming requests that use port 443
  - SSL termination enables secure traffic; it does not act as a block for HTTPS ports.

**Hint:** Decrypting at the gate.

### 7. Which Nginx directive specifies the port the server should listen on?

- The "port" directive
  - Nginx does not use a directive named "port" for binding to network sockets.
- **The "listen" directive** ✅
  - Correct! The "listen" directive defines the IP and port combination for the server block.
- The "connect" directive
  - Connect is often a method or action, but not the directive used for port binding in Nginx.
- The "open" directive
  - The "open" keyword is not used by Nginx to specify listener ports for incoming traffic.

**Hint:** Standard networking term.

### 8. In Nginx, what does the "root" directive define?

- The administrative password for the server root user
  - The "root" directive deals with filesystem paths for web content, not user account privileges.
- **The directory on disk where static web files are located** ✅
  - Correct! It sets the base directory that Nginx uses to search for requested files.
- The highest level of the Nginx configuration hierarchy
  - While there is a global context, the "root" directive specifically refers to file locations.
- A command used to re-initialize the server process
  - The "root" directive is a static configuration setting, not an operational command.

**Hint:** Where the files live.

### 9. What is the difference between "root" and "alias" in Nginx?

- There is no functional difference between the two
  - They process the relationship between the URI and the file path differently.
- **"root" appends the URI to the path; "alias" replaces it** ✅
  - Correct! Alias ignores the location match when looking for the file on the disk.
- "alias" is used exclusively for serving image files
  - Both directives can be used for any type of static content, including HTML and scripts.
- "root" provides a significant performance boost over alias
  - Both directives are highly efficient; the choice depends on path logic, not speed.

**Hint:** How the path is appended.

### 10. Which Nginx command is used to test the configuration for errors?

- `nginx -v`
  - This flag displays the version of Nginx currently installed on the system.
- **`nginx -t`** ✅
  - Correct! This flag checks the configuration files for syntax errors without applying them.
- `nginx -s reload`
  - This reloads the service, which may fail if the configuration contains errors.
- `nginx -check`
  - Nginx does not recognize a "-check" flag; "-t" is the standard for testing.

**Hint:** Test flag.

### 11. What is the purpose of the "worker_processes" directive?

- To limit the maximum number of concurrent guest users
  - User limits are managed by connection directives, not by the number of system processes.
- **To define the number of Nginx processes currently running** ✅
  - Correct! This is usually set to "auto" to match the number of available CPU cores.
- To schedule the specific times that the server is active
  - Nginx is a persistent service; it does not use this directive for time-based scheduling.
- To limit the number of developers allowed to edit the file
  - Access to configuration files is managed by OS permissions (chmod/chown), not Nginx directives.

**Hint:** Scalability and CPU cores.

### 12. Which directive is used to redirect HTTP traffic to HTTPS?

- The "move" directive
  - There is no "move" directive in Nginx; redirects are handled via "return" or "rewrite".
- **return 301 https://$host$request_uri;** ✅
  - Correct! This sends a Permanent Redirect status to the browser, forcing the secure protocol.
- The "proxy_set_header" directive
  - This modifies the headers passed to the backend, but does not trigger a browser redirect.
- The "listen 443" directive
  - This enables HTTPS listening but does not automatically redirect users coming from port 80.

**Hint:** Changing the response code.

### 13. What does the "worker_connections" directive define?

- The number of physical Ethernet cables in the server
  - This is a hardware specification and cannot be configured through Nginx software.
- **The maximum simultaneous connections per worker process** ✅
  - Correct! Combined with worker_processes, this determines the total capacity of the server.
- The number of administrative users allowed to connect
  - Administrative access is handled via SSH or similar protocols, not worker_connections.
- The maximum bandwidth speed allowed for the network
  - Bandwidth is managed by traffic shaping or ISP limits, not by process connection counts.

**Hint:** Max load per process.

### 14. Where is the main Nginx configuration file usually located on Linux?

- /var/www/html/nginx.conf
  - This directory is typically used for public web content, not system configuration files.
- **/etc/nginx/nginx.conf** ✅
  - Correct! On most Linux distributions, this is the default path for the main configuration.
- /home/user/nginx.conf
  - System-wide services do not store their primary configuration in local user home directories.
- /bin/nginx.conf
  - The /bin directory is reserved for executable binaries, not for configuration files.

**Hint:** Standard /etc path.

### 15. What is the purpose of "gzip" in Nginx?

- To provide end-to-end encryption for all web traffic
  - Encryption is handled by SSL/TLS; gzip is used specifically for data compression.
- **To compress files before transmission to save bandwidth** ✅
  - Correct! Compressing assets like HTML and CSS reduces load times and bandwidth usage.
- To create a backup archive of the entire website
  - Website backups are performed by separate utilities; gzip in Nginx is for real-time delivery.
- To delete outdated and temporary files from the disk
  - File cleanup is not a function of the gzip module; it only affects files being served.

**Hint:** Compressing data.

### 16. What does the "location /" block match?

- Only requests for the site homepage
  - This block acts as a prefix match and handles more than just the root index page.
- **Any request not matched by a more specific block** ✅
  - Correct! It serves as the catch-all handler for the root and all sub-paths without specific matches.
- Only static files located in the root directory
  - It matches based on the URI path, not the physical location of files on the server disk.
- No requests, as it is a reserved error block
  - This is the most fundamental block for defining how a website handles requests.

**Hint:** The base path.

### 17. Which directive is used to set a custom 404 error page?

- The "404_page" directive
  - There is no directive named "404_page"; Nginx uses a general error handling directive.
- **error_page 404 /custom_404.html;** ✅
  - Correct! This directive maps specific HTTP error codes to custom file paths or URIs.
- The "missing_file_redirect" directive
  - This is not a valid Nginx directive for handling resource-not-found errors.
- The "fail_timeout" directive
  - This is used in upstream blocks to define how long to wait before marking a server as down.

**Hint:** Handling errors.

### 18. What is the "try_files" directive commonly used for?

- To attempt to repair corrupted configuration files
  - Nginx does not have a directive for repairing its own configuration files automatically.
- **To check for file existence and fall back to a default** ✅
  - Correct! It is often used to route all non-file requests to index.html for modern SPAs.
- To upload multiple files to an external storage service
  - File uploads are handled by the client and application, not by the "try_files" directive.
- To remove unused or temporary files from the server
  - Cleanup is not a function of Nginx; "try_files" is used for request routing logic.

**Hint:** Single Page Apps (SPAs).

### 19. What is "Nginx FastCGI" used for?

- To optimize the delivery speed of the global internet
  - FastCGI is a local protocol for communication between Nginx and application processors.
- **To interface Nginx with a dynamic language processor** ✅
  - Correct! It is the standard way to connect Nginx to languages like PHP using PHP-FPM.
- To accelerate the download of large software packages
  - While it improves dynamic performance, it is not a general-purpose download accelerator.
- To provide encryption for the backend database
  - Database encryption is handled by the DB engine; FastCGI is a gateway protocol.

**Hint:** Connecting to PHP.

### 20. In load balancing, what does "weight" do?

- It measures the physical mass of the server hardware
  - Hardware weight is irrelevant to software-based load balancing configurations.
- **It assigns more traffic to servers with a higher value** ✅
  - Correct! This allows you to send more requests to servers with more powerful hardware.
- It sets the maximum body size for client file uploads
  - File upload limits are defined by "client_max_body_size," not by the "weight" parameter.
- It limits the data transfer speed of the network
  - Traffic shaping and rate limiting are separate functions from upstream server weighting.

**Hint:** Favoring certain servers.

### 21. What is the purpose of "proxy_set_header Host $host;"?

- To rename the server on the internal network
  - This directive passes metadata; it does not change the actual hostname of the server.
- **To pass the original requested domain to the backend** ✅
  - Correct! This ensures the backend server knows which domain the client is trying to reach.
- To hide the public IP address of the end user
  - The "Host" header identifies the destination, not the source IP of the client.
- To encrypt the metadata within the HTTP headers
  - Headers are passed in plain text (unless the entire connection is wrapped in SSL/TLS).

**Hint:** Preserving the domain name.

### 22. What does the "include" directive do in Nginx?

- It adds a new user to the global Nginx mailing list
  - Nginx is a local server application; it does not manage external mailing list subscriptions.
- **It pulls in configuration settings from an external file** ✅
  - Correct! It allows you to organize your configuration into smaller, manageable, and modular files.
- It adds a new physical node to the load balancer cluster
  - Cluster nodes are added within the "upstream" block, not via an "include" directive.
- It injects custom CSS directly into the served HTML files
  - Nginx serves files as-is; it does not typically modify the internal content of the files.

**Hint:** Modular configuration.

### 23. What is an Nginx "Module"?

- A spare hardware component for the physical server
  - In the context of Nginx, a module is a software extension, not physical hardware.
- **A plugin that adds specific features to the server** ✅
  - Correct! Modules add capabilities like image processing, LDAP support, or advanced caching.
- A specialized type of lightweight virtual machine
  - Nginx modules are part of the Nginx process and are not standalone virtual machines.
- A utility used to rotate and compress system logs
  - Log rotation is usually performed by system utilities like logrotate, not Nginx modules.

**Hint:** Extended functionality.

### 24. What is the "client_max_body_size" directive used for?

- To limit the physical dimensions of the server rack
  - Rack dimensions are a physical constraint, not a software configuration setting.
- **To set the maximum allowed size of a client request** ✅
  - Correct! This directive is essential for allowing or restricting large file uploads.
- To restrict the total number of users on the site
  - User limits are managed by connection directives, not by the body size of a request.
- To regulate the global internet speed for all clients
  - Internet speed is determined by the network provider and bandwidth, not Nginx request size.

**Hint:** Large file uploads.

### 25. What does "Stub Status" provide in Nginx?

- A list of broken internal links on the website
  - Broken link detection is a function of web crawlers or SEO tools, not Nginx.
- **A page displaying basic performance and connection metrics** ✅
  - Correct! It provides real-time data on active connections, accepted requests, and more.
- A utility for deleting old and unused configuration files
  - Status pages are for monitoring; they do not have the ability to delete system files.
- A registry containing all registered user accounts
  - Nginx does not maintain a user registry; this is handled by application databases.

**Hint:** Basic metrics.

### 26. What is the "keepalive_timeout" directive?

- The time before an inactive server is deleted
  - Servers are managed by the infrastructure layer, not by Nginx connection timeouts.
- **The time a connection stays open after a request** ✅
  - Correct! Keeping connections open reduces the overhead of re-establishing TCP/SSL handshakes.
- The maximum duration allowed for a developer to edit
  - This is not a technical configuration; access time is not managed by Nginx.
- The physical speed of the local area network
  - Network speed is a hardware and provider characteristic, not an Nginx directive.

**Hint:** Closing idle connections.

### 27. What is the purpose of "X-Forwarded-For" header?

- To send an automated response to an external email
  - This header is used for HTTP request tracking, not for email communication.
- **To identify the original IP address of the client** ✅
  - Correct! It allows backend servers to see the user’s IP instead of just the proxy’s IP.
- To provide a secure hash of the user password
  - Passwords should never be sent in headers; this header is for IP address tracking.
- To increase the caching speed of the web server
  - While metadata helps with logic, it does not directly increase the physical speed of the cache.

**Hint:** Identifying the real user.

### 28. In Nginx, what does the "events {}" block contain?

- A calendar list of all scheduled site maintenance
  - The events block is for process configuration, not for scheduling human-readable events.
- **Directives that manage the processing of connections** ✅
  - Correct! This is where you configure how worker processes handle new connections.
- A historical log of all previous system crashes
  - Crashes are logged in error files; they are not part of the active configuration block.
- A programming tool for writing and debugging HCL code
  - Nginx uses its own configuration syntax; it is not a tool for writing external code.

**Hint:** Core process settings.

### 29. What is "HSTS" (HTTP Strict Transport Security)?

- A method for increasing the physical server throughput
  - HSTS is a security policy; it does not directly affect the hardware throughput of the server.
- **A header that forces the browser to only use HTTPS** ✅
  - Correct! It prevents man-in-the-middle attacks by ensuring the client never uses HTTP.
- A cleanup utility for deleting old SSL certificates
  - Certificate management is an administrative task; HSTS is a browser-level security policy.
- A list of all users currently connected to the site
  - Nginx does not use HSTS to track or list individual user connections.

**Hint:** Forcing HTTPS in the browser.

### 30. Which command reloads the Nginx configuration without stopping the service?

- `nginx stop`
  - The stop command immediately halts the service, causing downtime for the website.
- **`nginx -s reload`** ✅
  - Correct! This starts new worker processes and gracefully shuts down the old ones.
- `nginx -restart`
  - A restart usually involves a full stop and start; reload is the standard for zero-downtime.
- `nginx -clean`
  - Nginx does not have a "clean" flag; reloading is handled by the signal command (-s).

**Hint:** Zero-downtime update.
