0
0
Nginxdevops~20 mins

Nginx vs Apache comparison - Practice Questions

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Nginx vs Apache Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Key difference in handling connections

Which statement correctly describes how Nginx and Apache handle client connections?

ABoth Nginx and Apache use process-driven, synchronous architectures.
BBoth Nginx and Apache use event-driven, asynchronous architectures.
CNginx uses an event-driven, asynchronous architecture, while Apache uses a process-driven, synchronous model.
DApache uses an event-driven, asynchronous architecture, while Nginx uses a process-driven, synchronous model.
Attempts:
2 left
💡 Hint

Think about how each server manages multiple requests at the same time.

💻 Command Output
intermediate
2:00remaining
Check active worker processes

What is the output of the following command on a server running Nginx?

ps aux | grep nginx | grep -v grep
AShows only one Nginx process running.
BShows multiple Nginx worker processes and one master process running.
CReturns a syntax error due to incorrect command.
DShows no output because Nginx is not running.
Attempts:
2 left
💡 Hint

Consider how Nginx manages its processes.

Configuration
advanced
3:00remaining
Load balancing configuration in Nginx

Which Nginx configuration snippet correctly sets up a simple round-robin load balancer for two backend servers?

A
upstream backend {
    server backend1.example.com weight=2;
    server backend2.example.com weight=3;
}

server {
    location / {
        proxy_pass http://backend;
    }
}
B
server {
    proxy_pass backend1.example.com backend2.example.com;
}
C
upstream backend {
    server backend1.example.com;
    server backend2.example.com;
    load_balance round_robin;
}

server {
    location / {
        proxy_pass http://backend;
    }
}
D
upstream backend {
    server backend1.example.com;
    server backend2.example.com;
}

server {
    location / {
        proxy_pass http://backend;
    }
}
Attempts:
2 left
💡 Hint

Look for the standard way to define upstream servers and proxy pass.

Troubleshoot
advanced
2:30remaining
Diagnosing 502 Bad Gateway error

You have Nginx configured as a reverse proxy to an application server. When accessing the site, you get a 502 Bad Gateway error. Which is the most likely cause?

AThe backend application server is not running or unreachable.
BNginx configuration file syntax error.
CNginx is running on a different port than the backend server.
DThe client browser cache is corrupted.
Attempts:
2 left
💡 Hint

502 means Nginx cannot get a valid response from the backend.

Best Practice
expert
3:00remaining
Optimizing static content delivery

Which Nginx configuration snippet best improves performance by efficiently serving static files?

A
location /static/ {
    root /var/www/html;
    expires 30d;
    add_header Cache-Control "public";
    try_files $uri =404;
}
B
location /static/ {
    proxy_pass http://backend;
    expires 30d;
}
C
location /static/ {
    root /var/www/html;
    proxy_cache off;
}
D
location /static/ {
    root /var/www/html;
    deny all;
}
Attempts:
2 left
💡 Hint

Think about caching headers and direct file serving.