Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a web server?
A web server handles HTTP requests from browsers and serves static content like HTML, CSS, and images. It listens for requests and sends back files or responses.
Click to reveal answer
beginner
What is an application server?
An application server runs business logic and dynamic content. It processes requests, runs code, and generates responses, often connecting to databases.
Click to reveal answer
intermediate
How does Nginx act as a web server?
Nginx serves static files quickly and efficiently. It listens on ports like 80 or 443 and sends requested files like images or HTML pages to users.
Click to reveal answer
intermediate
How can Nginx work with an application server?
Nginx can forward requests for dynamic content to an application server (like Node.js or Python). It acts as a reverse proxy, passing requests and returning responses.
Click to reveal answer
intermediate
Why use both a web server and an application server together?
Using both lets the web server handle static files fast, while the application server focuses on running code and generating dynamic content. This improves speed and organization.
Click to reveal answer
What is the main job of a web server?
ACompile application code
BRun business logic and code
CStore data in databases
DServe static files like images and HTML
✗ Incorrect
A web server mainly serves static files such as images, HTML, and CSS to users.
Which server type processes dynamic content and runs application code?
AApplication server
BWeb server
CDatabase server
DFile server
✗ Incorrect
An application server runs code and generates dynamic content based on requests.
How does Nginx commonly interact with an application server?
AIt replaces the application server
BIt forwards dynamic requests as a reverse proxy
CIt stores application data
DIt compiles application code
✗ Incorrect
Nginx often acts as a reverse proxy, forwarding requests for dynamic content to an application server.
Which port does a web server like Nginx usually listen on for HTTP traffic?
A80
B443
C22
D3306
✗ Incorrect
Port 80 is the default port for HTTP traffic handled by web servers.
Why is it beneficial to separate web server and application server roles?
ATo make the system slower
BTo reduce security
CTo improve performance and organization
DTo avoid using databases
✗ Incorrect
Separating roles lets each server focus on what it does best, improving speed and system organization.
Explain the difference between a web server and an application server in simple terms.
Think about what each server does when you visit a website.
You got /4 concepts.
Describe how Nginx can be used together with an application server to serve a website.
Consider how requests for images differ from requests for data.
You got /4 concepts.
Practice
(1/5)
1. What is the primary role of a web server like nginx?
easy
A. To deliver static files like images and HTML directly to users
B. To execute backend application logic and generate dynamic content
C. To store user data and manage databases
D. To compile source code into executable programs
Solution
Step 1: Understand the role of a web server
A web server mainly serves static content such as images, HTML, CSS, and JavaScript files directly to users.
Step 2: Differentiate from application server
An application server runs backend code to create dynamic content, which is different from a web server's role.
Final Answer:
To deliver static files like images and HTML directly to users -> Option A
Quick Check:
Web server = static file delivery [OK]
Hint: Web servers serve files; app servers run code [OK]
Common Mistakes:
Confusing web server with application server
Thinking web server runs backend logic
Assuming web server manages databases
2. Which nginx configuration snippet correctly forwards requests to an application server on port 3000?
easy
A. location / { root http://localhost:3000; }
B. location / { fastcgi_pass http://localhost:3000; }
C. location / { proxy_pass http://localhost:3000; }
D. location / { redirect http://localhost:3000; }
Solution
Step 1: Identify correct directive for forwarding
The proxy_pass directive is used in nginx to forward requests to an application server.
Step 2: Check other options for correctness
root serves static files, fastcgi_pass is for FastCGI servers, and redirect sends HTTP redirects, not proxying.
Final Answer:
location / { proxy_pass http://localhost:3000; } -> Option C
But requests to /api/users fail. What is the likely problem?
medium
A. nginx cannot forward requests to localhost
B. The location block should be location /api/ with trailing slash
C. proxy_pass must use HTTPS instead of HTTP
D. proxy_pass should be http://localhost:5000/ without /api
Solution
Step 1: Understand proxy_pass URI behavior
When proxy_pass includes a URI (like /api), nginx replaces the matching part of the request URI with that URI, causing duplication.
Step 2: Correct proxy_pass to avoid URI duplication
Removing /api from proxy_pass (using http://localhost:5000/) forwards the full original URI correctly.
Final Answer:
proxy_pass should be http://localhost:5000/ without /api -> Option D
Quick Check:
proxy_pass URI affects request path [OK]
Hint: Avoid URI in proxy_pass to prevent path duplication [OK]
Common Mistakes:
Including URI in proxy_pass causing double paths
Thinking HTTPS is required for localhost
Believing nginx can't proxy localhost
5. You want nginx to serve static files from /var/www/html and forward API requests to an application server on port 4000. Which configuration correctly achieves this?