How Apache and Nginx relate

A TurboStack host runs either Apache or Nginx, never both - what that means for TLS, Varnish and .htaccess.

A TurboStack host runs one web server, chosen with the webserver setting. Apache does not sit behind Nginx: setting webserver: apache2 removes Nginx from the host, and webserver: nginx removes Apache.

So with webserver: apache2, Apache is the front door. It terminates HTTPS, redirects HTTP to HTTPS, runs your application over PHP-FPM and reads .htaccess from your document root.

How requests flow

Without Varnish, there is one virtual host and one hop:

  1. The visitor reaches Apache over HTTPS.
  2. Apache serves the file, or hands the request to PHP-FPM, applying any .htaccess rules along the way.

With Varnish enabled, Apache runs twice:

  1. The visitor reaches a front virtual host, which holds the certificate and passes the request to Varnish.

  2. Varnish answers from its cache, or asks the backend virtual host - a plain Apache on the same machine, without HTTPS.

  3. The backend serves the request. This is the virtual host that has your document root, so it is the one that reads .htaccess.

That second case matters for access rules: anything in .htaccess is only evaluated when a request reaches the backend, so a page Varnish already holds is served without it. See Method 3 in Restrict access with basic authentication for how to apply a rule in front of the cache.

What you configure where

Concern Where
Transport Layer Security (TLS), HTTP-to-HTTPS redirect, caching (Varnish) The platform, from your host configuration
Per-directory rules, rewrites, access control, headers Apache .htaccess in your web root
Rules that must run before the cache ~/apache2/outside/50vhost_post.conf

When to choose Apache

Choose Apache when your application depends on .htaccess rules that it ships and maintains itself. If you do not need .htaccess, Nginx (webserver: nginx) is the lighter default - see Configure Nginx.