A user clicks the link http://www.kshb.example/schemes/list.php?district=Thrissur&type=rental#map. Which port is used, which parts reach the server, and what are the first two lines of the request?
A web server listens on port 80/443, parses HTTP requests, maps URLs to files or programs and returns responses. Apache, Nginx and IIS serve the web; Tomcat and full application servers run Java business logic behind them.
A web server is a program that serves resources over HTTP. It accepts connections from clients — browsers, mobile apps, search-engine crawlers — reads each request and sends back a response. The term also names the computer that runs this program.
Listen 80 in Apache, listen 443 ssl; in Nginx).GET /schemes/list.html HTTP/1.1) and the headers; reject malformed requests with 400 Bad Request.Host header to pick the right virtual host when one server carries many domains./var/www/kshb/schemes/list.html), an alias, a rewrite rule, or a handler for dynamic code.Content-Type, or run / proxy the dynamic code and stream its output; add headers such as Content-Length, Last-Modified and Cache-Control.Production servers do much more on the side: compress responses (gzip, Brotli), cache, limit request rates, terminate TLS on behalf of back-end servers, and serve thousands of clients concurrently.
Set-Cookie goes back to the browser.The Common Gateway Interface (CGI), defined at NCSA in 1993 and later written up as RFC 3875, was the first standard way to generate pages with a program. For every request the server starts a new process for the script (C, Perl, shell, Python), passes the request details in environment variables — REQUEST_METHOD, QUERY_STRING, CONTENT_LENGTH, CONTENT_TYPE, REMOTE_ADDR, HTTP_USER_AGENT — and feeds any POST body on standard input. Whatever the script prints on standard output (headers, a blank line, then the body) becomes the response.
#!/bin/sh
# hello.cgi — a complete CGI program; the server runs it once per request
echo "Content-Type: text/plain"
echo "" # the blank line ends the headers
echo "Method : $REQUEST_METHOD"
echo "Query : $QUERY_STRING"
echo "Browser: $HTTP_USER_AGENT"The cures all keep code resident. FastCGI runs a pool of long-lived worker processes and sends them requests over a socket, so start-up is paid once — PHP-FPM (FastCGI Process Manager) is how Nginx runs PHP. Server modules such as Apache's mod_php load the interpreter into the web server itself. Servlet containers like Tomcat handle each request on a thread inside one long-running JVM, and IIS runs ASP.NET inside pooled worker processes (w3wp.exe).
The Apache HTTP Server (httpd) grew out of patches to the NCSA HTTPd server in 1995 and is developed by the Apache Software Foundation. It is open source, runs on Linux, Windows and macOS, and for many years was the most widely used web server — it is the A in LAMP.
Apache is modular: a small core plus modules loaded with LoadModule — mod_ssl (HTTPS), mod_rewrite (URL rewriting), mod_alias, mod_proxy (reverse proxy), mod_deflate (compression), mod_auth_basic (passwords) and mod_php. A Multi-Processing Module (MPM) decides how connections map to processes and threads: prefork (one single-threaded process per connection, needed by non-thread-safe mod_php), worker (several processes, many threads each) and event (like worker, with a listener thread that parks idle keep-alive connections — the usual default today).
# httpd.conf (apache2.conf on Debian/Ubuntu): the main configuration file
Listen 80
ServerName www.kshb.example
DocumentRoot "/var/www/kshb"
# file served when the URL names a directory
DirectoryIndex index.php index.html
<Directory "/var/www/kshb">
# never generate a listing of the directory
Options -Indexes
# let .htaccess files in this tree override settings
AllowOverride All
Require all granted
</Directory>
ErrorLog "logs/error_log"
CustomLog "logs/access_log" combinedVirtual hosts let one Apache instance serve many sites. With name-based virtual hosting every block shares the same IP and port, and Apache chooses the block whose ServerName (or ServerAlias) matches the request's Host header; a request matching none goes to the first block listed.
<VirtualHost *:80>
ServerName portal.kshb.example
DocumentRoot "/var/www/portal"
</VirtualHost>
<VirtualHost *:80>
ServerName www.tourism.example
ServerAlias tourism.example
DocumentRoot "/var/www/tourism"
</VirtualHost>A .htaccess file placed in a directory overrides configuration for that directory and everything below it — useful on shared hosting where users cannot edit httpd.conf. Apache re-reads these files on every request, so they cost performance; with root access, put the same directives in the main configuration.
# .htaccess in the document root /var/www/kshb
# 1. permanently move an old page (the browser receives 301 + Location)
Redirect 301 /old-schemes.html /schemes/
# 2. pretty URLs: /scheme/42 is served by scheme.php?id=42
RewriteEngine On
RewriteRule ^scheme/([0-9]+)$ scheme.php?id=$1 [L]Apache keeps two main logs: the access log (access_log or access.log, one line per request) and the error log (error_log or error.log: start-up messages, missing files, script errors). A line in the combined format looks like this:
203.0.113.7 - - [03/Dec/2026:10:15:32 +0530] "GET /schemes.php?district=Kollam HTTP/1.1" 200 5120 "https://www.kshb.example/" "Mozilla/5.0 (Windows NT 10.0)"Nginx (pronounced engine-x) was written by Igor Sysoev and released in 2004 to solve the C10K problem — serving ten thousand simultaneous clients on one machine. Today it is one of the two most widely used web servers (with Apache) and the usual front end of busy sites.
Apache's classic models give each connection its own process or thread, so 10,000 idle keep-alive connections mean 10,000 mostly sleeping threads. Nginx instead runs one master process and a few worker processes (usually one per CPU core). Each worker runs an event loop over non-blocking sockets (epoll on Linux, kqueue on BSD) and juggles thousands of connections, working only when a socket is ready. Memory use stays low and predictable.
# nginx.conf (excerpt)
upstream app_servers {
least_conn; # send each request to the least-busy back end
server 10.0.0.11:8080;
server 10.0.0.12:8080;
}
server {
listen 443 ssl;
server_name portal.kshb.example;
ssl_certificate /etc/nginx/tls/portal.crt;
ssl_certificate_key /etc/nginx/tls/portal.key;
root /var/www/portal;
location /static/ { expires 7d; } # static files served straight from disk
location ~ \.php$ { # PHP handed to PHP-FPM over FastCGI
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
location /api/ { proxy_pass http://app_servers; } # reverse proxy + load balancing
}A reverse proxy stands in front of servers and receives requests on their behalf. Clients see one address; the proxy forwards each request to a back end, caches responses, terminates TLS, compresses, and spreads the load over several back ends — load balancing by round robin (the default), least connections or client-IP hashing (ip_hash, which keeps a client on one server). A forward proxy is the mirror image: it sits in front of clients, such as an office proxy that fetches pages for employees.
Internet Information Services (IIS) is Microsoft's web server, shipped with Windows Server and Windows (current major version IIS 10). A kernel-mode driver, http.sys, receives requests and queues them to application pools; each pool runs one or more worker processes (w3wp.exe) that execute the code, isolated from other pools. IIS hosts ASP.NET (and classic ASP), static sites and FTP, and is configured through IIS Manager, applicationHost.config and per-application web.config files.
Apache Tomcat is an open-source servlet container (web container). It implements the Jakarta Servlet, Jakarta Server Pages (JSP), Expression Language and WebSocket specifications, so it can run Java web applications. Its main parts are Catalina (the servlet container), Coyote (the HTTP connector, default port 8080) and Jasper (the JSP engine that translates .jsp pages into servlets and compiles them). Applications are deployed by copying a WAR (Web ARchive) into webapps/; configuration lives in conf/server.xml and conf/web.xml, and output goes to logs/catalina.out.
| Server | Vendor / licence | Implements | Notes |
|---|---|---|---|
| Apache Tomcat | ASF, open source | Servlet, JSP, EL, WebSocket | Web container only — no EJB |
| WildFly (formerly JBoss AS) | Red Hat, open source (JBoss EAP is the commercial build) | Full Jakarta EE | EJB, JMS, JTA, clustering |
| Oracle WebLogic | Oracle, commercial | Full Jakarta EE | Common in banks and telecoms |
| IBM WebSphere | IBM, commercial (Liberty is the lightweight edition) | Full Jakarta EE | Strong mainframe integration |
| GlassFish | Eclipse Foundation (originally Sun), open source | Full Jakarta EE | Long the reference implementation |
| IIS with .NET | Microsoft | ASP.NET | Windows hosting for ASP.NET |
An application server provides a run-time environment for business logic. Besides a web container it offers an EJB container, distributed transactions (JTA), messaging (JMS), security, JNDI naming, database connection pools and clustering. In three-tier terms the application server is the middle tier.
| Aspect | Web server | Application server |
|---|---|---|
| Main job | Serve HTTP: static files, proxying | Run business logic and components |
| Content | Static, plus dynamic through modules/CGI/FastCGI | Dynamic: servlets, EJBs, services |
| Protocols | HTTP / HTTPS | HTTP plus RMI/IIOP, JMS, and more |
| Services | Caching, compression, TLS, virtual hosts | Transactions, connection pooling, messaging, security, clustering |
| Resource use | Light | Heavier (JVM or .NET run-time) |
| Examples | Apache httpd, Nginx, IIS (for static sites) | WildFly, WebLogic, WebSphere, GlassFish |
Every response names the type of its body in the Content-Type header using a MIME type (Multipurpose Internet Mail Extensions, RFC 2045–2049 — designed for e-mail attachments and reused by HTTP). A MIME type has the form type/subtype, optionally with parameters such as charset=UTF-8. Servers map file extensions to types with a table (mime.types, Apache's AddType); a wrong type makes browsers mishandle the file — a stylesheet served as text/plain is simply ignored.
| MIME type | Used for |
|---|---|
text/html | HTML pages |
text/css | CSS style sheets |
text/javascript | JavaScript (RFC 9239); application/javascript is the older, still common form |
text/plain | Plain text |
application/json | JSON data for AJAX and REST APIs |
application/xml, text/xml | XML documents |
image/png, image/jpeg, image/gif, image/svg+xml | Images |
application/pdf | PDF documents |
application/x-www-form-urlencoded | Default body of a submitted form |
multipart/form-data | Forms that upload files |
application/octet-stream | Arbitrary binary data; usually triggers a download |
video/mp4, audio/mpeg | Media files |
text/css — not application/css or text/html (asked in a 2026 PSC paper).A URL (Uniform Resource Locator) tells the browser which server to contact and what to ask it for. Take this example:
https://anil:pw@portal.kshb.example:8443/schemes/list.php?district=Kollam&page=2#results| Part | In the example | Notes |
|---|---|---|
| Scheme | https | Protocol; implies default port 443 (http implies 80) |
| User info | anil:pw@ | Optional credentials — obsolete and unsafe; browsers warn about it |
| Host | portal.kshb.example | Domain name (resolved by DNS) or an IP address; sent in the Host header |
| Port | 8443 | Optional; omitted when it is the scheme's default |
| Path | /schemes/list.php | Which resource on that host |
| Query | ?district=Kollam&page=2 | name=value pairs joined by &, read by server code (PHP's $_GET) |
| Fragment | #results | A position inside the page — never sent to the server |
Only a limited set of ASCII characters may appear in a URL. Anything else is percent-encoded as % followed by two hex digits for each UTF-8 byte: a space becomes %20 (or + inside form data), & becomes %26, / becomes %2F. A URL says where a resource is; a URN only names it (urn:isbn:…); both are kinds of URI.
Host header to choose the site. For HTTPS the name is needed before the certificate is chosen, so TLS carries it in the SNI (Server Name Indication) extension. Shared hosting works this way.:8080, :8081); used internally rather than for public sites.Host mandatory in HTTP/1.1? The request line carries only the path, so without Host a server holding many sites on one IP address could not tell which one you want.| Stack | Components | Typical use |
|---|---|---|
| LAMP | Linux, Apache, MySQL/MariaDB, PHP (or Perl/Python) | Classic open-source hosting: WordPress, Moodle |
| WAMP / XAMPP | Windows (or cross-platform 'X'), Apache, MariaDB/MySQL, PHP, Perl | Local development and teaching labs |
| LEMP | Linux, Nginx (engine-x), MySQL, PHP-FPM | High-traffic PHP sites |
| MEAN / MERN | MongoDB, Express.js, Angular or React, Node.js | JavaScript end to end; single-page apps and APIs |
| Java stack | Linux, Apache/Nginx, Tomcat or WildFly, Oracle/MySQL | Enterprise and government portals |
| WISA | Windows Server, IIS, SQL Server, ASP.NET | Microsoft-based organisations |
Node.js blurs the categories: a Node program (often with the Express framework) is its own web server, running JavaScript on an event loop much like Nginx. In production it usually still sits behind Nginx for TLS and static files.
Try the problem first, then reveal the working one step at a time.
A user clicks the link http://www.kshb.example/schemes/list.php?district=Thrissur&type=rental#map. Which port is used, which parts reach the server, and what are the first two lines of the request?
An Apache server at 203.0.113.10 has the two name-based virtual hosts shown in the Apache section (portal.kshb.example listed first, www.tourism.example second, with ServerAlias tourism.example). Which DocumentRoot serves each request? (a) Host: tourism.example (b) Host: portal.kshb.example (c) Host: 203.0.113.10 (someone typed the IP).
A site receives 400 dynamic requests per second. Under CGI each request costs 12 ms of CPU to start a process and interpreter plus 3 ms of useful work. Under FastCGI the workers are already running, so only the 3 ms of work remains. How many CPU cores does each approach keep busy?
Choose a server (or combination) for: (a) a static information site; (b) a JSP/servlet application with no EJBs; (c) a Jakarta EE application using EJBs and JMS queues; (d) an ASP.NET Web Forms application; (e) a high-traffic PHP portal.
Give the correct Content-Type for: (a) logo.svg (b) report.pdf (c) site.css (d) a JSON response from an API (e) a form that uploads a photo (f) a downloadable setup.exe.
Interpret this Apache access-log line: 198.51.100.23 - - [03/Dec/2026:11:02:10 +0530] "POST /login.php HTTP/1.1" 302 - "https://portal.kshb.example/login.php" "Mozilla/5.0"
A user requests http://www.kshb.example/docs/ and the docs directory has no index.html or index.php. What does Apache return with Options -Indexes, and with Options +Indexes?
A server must hold 20,000 mostly idle keep-alive connections. Prefork Apache uses one process per connection at about 10 MB each; assume Nginx needs about 10 KB per idle connection in 4 workers. Estimate the memory each needs and explain the difference.
Write an Nginx configuration fragment that forwards every request under /api/ to two Tomcat servers, 10.0.0.21:8080 and 10.0.0.22:8080, using the default load-balancing method.
#part) never reaches the server; the query string (?a=1) does..htaccess changes take effect without a restart, but the files are read on every request — slower than the same directives in httpd.conf.text/css; JSON is application/json; for JavaScript the current standard is text/javascript, though application/javascript is still widely seen.Options -Indexes # comment is a syntax error.10 questions. 70 % passes the topic quiz (+30 XP, +20 more for 100 %). Exam scoring: +1 correct, −⅓ wrong.
Modelled on real KPSC questions (reworded) with the same concept and answer; each links to its original paper.