Web Server
- In Turkish
- Web Sunucusu
In short
A web server is software, or the machine running it, that accepts HTTP requests from browsers and other clients and responds with pages, files, or data.
What is a web server?
A web server is a program that listens for HTTP requests on a network port, usually 80 for HTTP and 443 for HTTPS, and sends back responses. The term can mean the software itself or the physical or virtual machine it runs on. When you type a URL, your browser sends a request to a web server, which returns the HTML, CSS, images, or JSON the page needs.
Web servers deliver two kinds of content. Static content, such as images, stylesheets, and prebuilt HTML files, is read from disk and sent as-is, which is very fast, while dynamic content is generated for each request by application code, so the web server passes those requests to an application server or runtime and relays its response. Widely used web servers include NGINX, Apache HTTP Server, Caddy, and Microsoft IIS, and they also commonly handle HTTPS encryption, compression, logging, and redirects.
Think of a web server as the front counter of a bakery: ready-made bread (static files) is handed over immediately, while custom cake orders (dynamic requests) are passed to the kitchen and delivered when ready. Most websites run a web server in front of their application, and the same program often also acts as a reverse proxy and load balancer.
A web server is often confused with an application server. A web server focuses on handling HTTP connections and serving files efficiently, while an application server runs your business logic, such as a Node.js, Python, or Java app. The line is blurry, because many runtimes, such as Node.js, include their own HTTP server, but in production a dedicated web server or reverse proxy often sits in front of them.
Key takeaways
- A web server receives HTTP requests and returns responses such as HTML, files, or JSON.
- It usually listens on port 80 for HTTP and port 443 for HTTPS.
- Static files are served directly; dynamic requests are passed to application code.
- Common extra jobs include TLS encryption, compression, logging, and redirects.
- An application server runs business logic; a web server handles HTTP and files.
Example
server {
listen 80;
server_name example.com;
# Static content: read files straight from disk
location / {
root /var/www/example;
try_files $uri $uri/ /index.html;
}
# Dynamic content: pass to an app listening on port 3000
location /api/ {
proxy_pass http://127.0.0.1:3000;
}
}Readers ask
What is the difference between a web server and an application server?
A web server handles HTTP connections and serves static files efficiently, while an application server runs the code that builds dynamic responses, such as reading from a database. In many setups a web server sits in front and forwards dynamic requests to the application server.
Is a web server hardware or software?
Both meanings are used. Strictly, the web server is the software that handles HTTP, such as NGINX or Apache, but people also call the machine that runs it a web server.
What is the difference between a web server and a reverse proxy?
A web server answers requests itself, for example by returning files. A reverse proxy forwards requests to other servers and relays their responses, and many web servers, such as NGINX, can do both.
See also
- HTTPWeb Development, p. 19HTTP is the protocol that browsers, apps, and servers use to exchange web pages and data through a simple cycle of requests and responses.
- Reverse ProxyDevOps & Cloud, p. 44A reverse proxy is a server that sits in front of web servers, accepts client requests on their behalf, and forwards each request to the right backend server.
- Load BalancerDevOps & Cloud, p. 34A load balancer is a server or service that spreads incoming traffic across several backend servers so no single one is overloaded and the app stays available.
- Node.jsBackend & APIs, p. 32Node.js is an open-source JavaScript runtime that runs JavaScript outside the browser, most often to build web servers, APIs, and command-line tools.
- HTTPSSecurity, p. 17HTTPS is the secure version of HTTP that encrypts traffic between a browser and a website with TLS, protecting data from eavesdropping and tampering.
- PortNetworking, p. 22A port is a number from 0 to 65535 that identifies a specific program or service on a device, so traffic reaching an IP address gets to the right application.
- NginxBackend & APIs, p. 31Nginx is a fast, open-source web server that is also widely used as a reverse proxy, load balancer and HTTP cache in front of application servers.
Spotted a mistake or something missing on this page?Suggest an edit