Instiq
Chapter 3 · HTTP servers and proxy servers·v1.0.0·Updated 7/7/2026·~13 min

What's changed: Initial version (topic 2.09, subtopics 2.09.1–2.09.4)

3.3Configuring and Managing nginx

Key points

Learn nginx basics and its use as a reverse proxy: the configuration directory /etc/nginx/, control via the nginx command, enabling HTTPS with the ssl directives (ssl_certificate, ssl_certificate_key, ssl_ciphers, ssl_protocols), forwarding to a backend with proxy_pass, and tuning proxy behavior with proxy_http_version and proxy_set_header.

nginx is widely used both as a standalone web server and, thanks to its high concurrency, as a reverse proxy in front of multiple application servers. Its directive names look similar to Apache's but often differ in detail—a favorite source of confusable exam questions at L2.

3.3.1Configuration and control

  • Configuration files live under /etc/nginx/ (the main file is typically nginx.conf, with per-site configs under conf.d or sites-available, etc.). After editing, apply changes via the nginx command's syntax-check and reload options.
  • Enabling HTTPS combines several ssl-related directives: ssl_certificate (certificate), ssl_certificate_key (private key), ssl_protocols (allowed protocols), and ssl_ciphers (allowed cipher suites). These map conceptually to Apache's equivalents but use different directive names—a key distinction to keep straight.

3.3.2Configuration as a reverse proxy

  • proxy_pass specifies the backend URL to forward requests to (e.g., proxy_pass http://127.0.0.1:8080;)—the core directive in the typical pattern where nginx receives requests up front and hands off processing to an application server.
  • proxy_http_version specifies the HTTP version used to talk to the backend (the default is HTTP/1.0, so it is often explicitly set to 1.1 for things like WebSocket upgrades).
  • proxy_set_header adds or rewrites request headers forwarded to the backend—the standard way to pass the client's original Host or IP address through to the backend.
Exam point

The most common confusion: Apache's SSLCertificateFile corresponds to nginx's ssl_certificate (underscored, lowercase), and Apache's SSLProtocol corresponds to nginx's ssl_protocols—the naming and spelling differences matter. Also standard: forwarding to a backend = proxy_pass, adding headers for the backend = proxy_set_header, switching to HTTP/1.1 = proxy_http_version.

Trace a typical setup: nginx in front, forwarding to a backend application server. In a server block under /etc/nginx/, write listen 443 ssl;, then specify the certificate file with ssl_certificate and the key file with ssl_certificate_key. Coming from Apache, it is tempting to write SSLCertificateFile-style names, but nginx uses underscore-separated, lowercase directives—a trap in both the exam and practice. Further narrow the allowed protocols with something like ssl_protocols TLSv1.2 TLSv1.3; and exclude weak ciphers with ssl_ciphers. Once TLS is terminated, the basic pattern for handing the request to the backend is proxy_pass http://127.0.0.1:8080; inside a location / block. If the backend connection needs HTTP/1.1 features (such as a WebSocket upgrade), set proxy_http_version 1.1; explicitly, since the default HTTP/1.0 cannot support it. In addition, use proxy_set_header to pass the client's original Host and IP through to the backend (e.g., proxy_set_header Host $host;, proxy_set_header X-Real-IP $remote_addr;). Omitting this makes every request look to the backend application as if it came from nginx itself, breaking IP-based logging and access control that depends on the real client address.

Purposenginx directiveApache equivalent
Specify certificatessl_certificateSSLCertificateFile
Specify private keyssl_certificate_keySSLCertificateKeyFile
Allowed protocolsssl_protocolsSSLProtocol
Allowed ciphersssl_ciphersSSLCipherSuite
Warning

Trap: options that write Apache-style directive names ("SSLCertificateFile", "SSLProtocol") into an nginx config are wrong—nginx uses underscore-separated, lowercase names like ssl_certificate, ssl_protocols. Also wrong: "the backend still sees the original client IP even without proxy_set_header"—omitting it makes the connection appear to originate from nginx itself; the original client IP is lost unless headers like X-Real-IP are explicitly forwarded.

Diagram contrasting nginx ssl_certificate-family directives with Apache equivalents, and a reverse proxy setup via proxy_pass/proxy_set_header.
nginx uses lowercase, underscored ssl_*

3.3.3Section summary

  • Config under /etc/nginx/; TLS via ssl_certificate, ssl_certificate_key, ssl_protocols, ssl_ciphers (spelled differently from Apache)
  • Reverse proxy: forward with proxy_pass, tune HTTP version with proxy_http_version, propagate client info with proxy_set_header

Sign in to track progress — Log in.

Quick check

(just a quick review)

Q1. You want to enable HTTPS in nginx and specify the certificate file. Which directive is correct?

Q2. You want nginx, as a reverse proxy, to forward incoming requests to an application running on localhost port 8080. Which directive?

Q3. In an nginx reverse proxy setup, you want the backend application to learn the original client IP address. Which directive should you use?

Check your understandingPractice questions for Chapter 3: HTTP servers and proxy servers