Web Server

Updated: 2020-06-29

Features of Web Server

  • Static file serving.
  • SSL/TLS support.
  • Virtual hosts.
  • Reverse proxying.
  • Load balancing.
  • Compression.
  • Access controls.
  • URL rewriting.
  • Custom logging.
  • Server-side includes.
  • Limited WebDAV.
  • FLV streaming.
  • FastCGI.

Forward Proxy vs Reverse Proxy

In computer networks, a reverse proxy is a type of proxy server that retrieves resources on behalf of a client from one or more servers. These resources are then returned to the client as though they originated from the proxy server itself.

  • a forward proxy acts as an intermediary for its associated clients to contact any server,
  • a reverse proxy acts as an intermediary for its associated servers to be contacted by any client.

Event-based vs Process-based

The main advantage of the asynchronous approach is scalability. In a process-based server, each simultaneous connection requires a thread which incurs significant overhead. An asynchronous server, on the other hand, is event-driven and handles requests in a single (or at least, very few) threads.

Nginx vs Apache Http Server

  • Nginx: event-based
  • Apache: process-based

Nginx is faster at serving static files and consumes much less memory for concurrent requests. Because Nginx is event-based, it doesn't need to spawn new processes or threads for each request, so its memory usage is very low.


499 is a non-standard status code used by nginx: if a client closes the connection while nginx is processing the request.

E.g. if nginx is used as reverse proxy, it will wait for the backend server(e.g. uWSGI) for X seconds, after that it will respond to the client with a 504 Gateway Timeout error. If the backend server is dead or dies while nginx is waiting, nginx sees that right away and returns 499 error

Nginx Restart

$ sudo nginx -s reload


WSGI, Java Servlet

On one side: full web server like Apache or Nginx; on the other side: application. WSGI is the middleware that implements both API.

Java's servlet API makes it possible for applications written with any Java web application framework to run in any web server that supports the servlet API.