What is a web server, and how is it different from your laptop?
"Web server" can mean two things: a computer that hosts websites, and the software on it that answers browser requests. Both are worth understanding.
The software side
Web server software listens for HTTP requests on a network port and sends back responses. Common jobs include:
- Serving static files like HTML, CSS, images and JavaScript
- Passing requests to an application (written in Node.js, Python, PHP, and so on) that builds pages dynamically
- Handling HTTPS certificates
- Compressing responses, caching, and logging requests
Well-known examples include Nginx, Apache and Caddy. Many frameworks also include a built-in development server.
The hardware side
A server is just a computer, often in a data center. In fact, when you run a local development server, your laptop is acting as a web server. The differences with a production server are about the environment:
- Always on: servers run 24/7 with reliable power and internet.
- Public address: reachable from the internet via a public IP and domain name, while your laptop usually sits behind a home router.
- No screen or desktop: usually managed remotely over SSH.
- Built for reliability: redundant disks and power supplies, monitoring and backups.
- Security hardening: firewalls, updates and minimal installed software.
Where your site might live
- Shared hosting, a VPS, a cloud instance, or a platform that manages servers for you.
Beginner tip
localhost means "this computer." A site running at localhost:3000 is only visible to you, which is why sending that link to a friend does not work.
Discussion:
- What was your first web server setup?
- Have you ever tried hosting a site from a computer at home?
Comments · 3
Nginx and Apache are the best-known web server software. In many setups Nginx also sits in front as a reverse proxy to handle TLS and static files, so your app only deals with the logic.
A web server is a computer that's very patient and never gets to go outside. I relate.
Could my laptop act as a web server for a small project, or is there a reason to avoid that?