




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. What primary function does NGINX serve when configured as a web server? A) Encrypts traffic between client and backend B) Serves static files and forwards dynamic requests to upstreams C) Balances load across multiple databases D) Generates TLS certificates on the fly Answer: B Explanation: In web‑server mode NGINX reads files from the file system (HTML, CSS, images) and can proxy dynamic requests to application servers. Question 2. Which NGINX role is best suited for caching frequently requested content? A) Reverse proxy B) Content cache C) API gateway D) Load balancer Answer: B Explanation: The content‑cache role stores responses locally so subsequent requests are served without contacting the origin server. Question 3. When would you choose NGINX over a traditional Apache server? A) When you need per‑directory .htaccess files
B) When you require high concurrency with low memory usage C) When you need built‑in CGI support D) When you need a Windows‑only solution Answer: B Explanation: NGINX’s event‑driven, non‑blocking architecture handles many simultaneous connections using little memory, making it ideal for high‑traffic sites. Question 4. In NGINX’s process model, what is the responsibility of the master process? A) Directly handling client connections B) Reading configuration files and spawning worker processes C) Performing SSL termination for each request D) Logging request details to disk Answer: B Explanation: The master process parses nginx.conf, validates syntax, and creates/monitors worker processes that do the actual request handling. Question 5. What does a worker process do in NGINX? A) Manage DNS resolution for upstream servers B) Serve static content and proxy dynamic requests C) Compile configuration directives into machine code D) Rotate log files automatically
Question 8. If you set worker_connections 1024; what does this limit? A) Maximum simultaneous client connections per worker B) Number of upstream servers in an upstream block C) Size of the request body in kilobytes D) Number of log files that can be open simultaneously Answer: A Explanation: worker_connections defines the maximum number of simultaneous connections a single worker can handle. Question 9. Which command gracefully reloads NGINX configuration without dropping existing connections? A) nginx - s stop B) nginx - s reload C) systemctl restart nginx D) nginx - t Answer: B Explanation: nginx - s reload sends a signal to the master to start new workers with the updated config while old workers finish current requests. Question 10. What does the nginx - t command verify? A) That all log files are writable B) Syntax correctness of the configuration files
C) That the SSL certificates are valid D) That the server is reachable from the internet Answer: B Explanation: -t tests the configuration for syntax errors and attempts to load the configuration without starting the server. Question 11. Where is the default main configuration file for NGINX located on most Linux distributions? A) /etc/nginx/nginx.conf B) /usr/local/nginx/conf/nginx.conf C) /var/www/nginx.conf D) /opt/nginx/config/main.conf Answer: A Explanation: The standard location for the primary configuration file is /etc/nginx/nginx.conf. Question 12. In the NGINX configuration hierarchy, which context is the top‑most? A) http B) server C) events D) main (or “global”) Answer: D
A) Child blocks override parent directives, but inherit any not redefined B) Child blocks must repeat every directive explicitly C) Parent directives are ignored if a child block exists D) Inheritance only works for location blocks, not server blocks Answer: A Explanation: Directives defined in http are inherited by server and location unless overridden locally. Question 16. Which directive defines a virtual host that listens on port 8080 for any IP address? A) listen 8080; B) server_name *:8080; C) bind 0.0.0.0:8080; D) listen *:8080 default_server; Answer: A Explanation: listen 8080; inside a server block tells NGINX to accept connections on port 8080 on all interfaces. Question 17. What does the default_server flag do when added to a listen directive? A) Marks the server block as the first to be evaluated for a request without a matching Host header B) Forces all traffic to be redirected to HTTPS
C) Enables HTTP/2 on that server block D) Disables logging for that virtual host Answer: A Explanation: default_server designates the server block that handles requests that do not match any other server_name. Question 18. How can you match a request for the exact URI /about in a location block? A) location = /about { … } B) location /about { … } C) location ~ ^/about$ { … } D) location ^~ /about { … } Answer: A Explanation: The = modifier creates an exact match; NGINX stops searching once it finds this location. Question 19. Which location modifier performs a case‑insensitive regular expression match? A) = B) ~* C) ^~ D) ~ Answer: B
Question 22. Which directive tells NGINX which file to serve when a directory is requested? A) default_type B) index C) root D) try_files Answer: B Explanation: The index directive lists files (e.g., index.html) that NGINX will look for and serve when a directory URI is accessed. Question 23. What does the try_files $uri $uri/ /index.html; directive achieve for a Single Page Application? A) It forces all requests to be proxied to a backend server B) It attempts to serve the exact file, then a directory, and finally falls back to index.html C) It disables caching for all static assets D) It returns a 404 error if the file does not exist Answer: B Explanation: try_files checks each argument in order; if none exist, the request is internally rewritten to /index.html, enabling client‑side routing. Question 24. How do you include the standard MIME type definitions in an NGINX configuration?
A) include /etc/nginx/mime.types; B) load_mime_types on; C) mime.types default; D) import mime.types; Answer: A Explanation: The include directive pulls in the mime.types file, which maps extensions to Content-Type headers. Question 25. Which directive is used for a simple HTTP 301 redirect from /old to /new? A) rewrite ^/old$ /new permanent; B) return 301 /new; C) redirect 301 /old /new; D) proxy_redirect /old /new; Answer: B Explanation: return 301 /new; sends a 301 status with the new location without evaluating further rewrite rules. Question 26. If you need to rewrite URLs using a regular expression and continue processing other rewrite directives, which flag should you use? A) last B) permanent C) break
Explanation: Adding the ssl parameter to the listen directive activates TLS for that socket. Question 29. What files are required to enable TLS for an NGINX server block? A) ssl_certificate and ssl_certificate_key B) ssl_dhparam and ssl_trusted_certificate C) ssl_crl and ssl_stapling_file D) ssl_private_key and ssl_public_key Answer: A Explanation: ssl_certificate points to the public cert (or full chain) and ssl_certificate_key to the private key. Question 30. Which directive forces all HTTP traffic to be redirected to HTTPS? A) return 301 https://$host$request_uri; B) rewrite ^ https://$host$request_uri permanent; C) both A and B are valid D) listen 80 ssl; Answer: C Explanation: Both a return with a 301 status or a rewrite … permanent achieve the same redirection effect.
Question 31. Which SSL protocols should be disabled to avoid weak encryption? A) TLSv1.2 and TLSv1. B) SSLv2 and SSLv C) TLSv1.0 and TLSv1. D) Both B and C Answer: D Explanation: SSLv2, SSLv3, TLSv1.0, and TLSv1.1 are considered insecure and should be excluded via ssl_protocols. Question 32. How can you enable HTTP Strict Transport Security (HSTS) for 1 year? A) add_header Strict-Transport-Security "max-age=31536000"; B) set_header HSTS "1y"; C) enable_hsts on; D) ssl_hsts 31536000; Answer: A Explanation: The add_header directive injects the Strict-Transport-Security header with the specified max‑age. Question 33. Which directives are used to set up basic authentication for a protected location? A) auth_basic "Restricted"; auth_basic_user_file /etc/nginx/.htpasswd;
Answer: A Explanation: TLS termination means NGINX handles the SSL handshake, decrypts data, and then proxies the request as HTTP. Question 36. Which directive forwards the original client IP to the backend server? A) proxy_set_header X-Real-IP $remote_addr; B) proxy_pass_header X-Forwarded-For; C) proxy_forward_ip $client_ip; D) proxy_send_ip $remote_addr; Answer: A Explanation: Setting X-Real-IP (or X-Forwarded-For) passes the client’s IP address in a header the backend can read. Question 37. How do you define an upstream group named app_servers with three backend servers? A) upstream app_servers { server 10.0.0.1; server 10.0.0.2; server 10.0.0.3; } B) backend app_servers { host 10.0.0.1; host 10.0.0.2; host 10.0.0.3; } C) pool app_servers { member 10.0.0.1; member 10.0.0.2; member 10.0.0.3; } D) server_group app_servers { server 10.0.0.1; server 10.0.0.2; server 10.0.0.3; } Answer: A Explanation: The upstream block lists server directives that belong to the named pool.
Question 38. Which load‑balancing method is the default for an NGINX upstream block? A) least_conn B) ip_hash C) round_robin D) random Answer: C Explanation: If no method is specified, NGINX uses round‑robin to distribute requests evenly. Question 39. How can you configure an upstream server to receive half the traffic of the default server? A) server 10.0.0.2 weight=2; B) server 10.0.0.2 weight=0.5; C) server 10.0.0.2 weight=1; server 10.0.0.1 weight=2; D) server 10.0.0.2 backup; Answer: C Explanation: Weights are relative; setting weight 2 for one server and weight 1 for another gives the first twice the traffic. Question 40. What does the backup parameter do in an upstream server definition?
D) write_log /var/log/nginx/access.log; Answer: B Explanation: access_log defines the file path for request logging. Question 43. What is the purpose of the log_format directive? A) To rotate log files automatically B) To define a custom log line layout using variables C) To enable binary logging for higher performance D) To set the maximum size of a log file Answer: B Explanation: log_format creates a named format that can be referenced by access_log to control which variables are written. Question 44. Which log level will record only critical errors in the error log? A) notice B) warn C) error D) crit Answer: D Explanation: The crit level logs only critical conditions; lower levels (error, warn, notice) log more messages.
Question 45. If you see many 502 Bad Gateway entries in the error log, what is the most likely cause? A) The client sent malformed HTTP headers B) NGINX could not establish a connection to the upstream server C) Disk space is full on the NGINX host D) The access log format is invalid Answer: B Explanation: A 502 typically indicates that NGINX, acting as a proxy, failed to get a valid response from the backend. Question 46. Which variable contains the name of the virtual host that processed the request? A) $host B) $server_name C) $http_host D) $server_addr Answer: B Explanation: $server_name expands to the value of the server_name directive that matched the request. Question 47. What does the $remote_addr variable represent? A) The IP address of the upstream server B) The IP address of the client making the request