How to run Apache behind Nginx
On TurboStack, Apache runs as a backend behind nginx. Nginx handles the edge - Transport Layer Security (TLS), static files and
(if enabled) the Varnish cache - and forwards dynamic requests to Apache, which runs your application
and reads .htaccess. This gives you Apache's per-directory flexibility with Nginx's performance at
the front.
How requests flow
-
A request arrives at Nginx (and Varnish, if enabled), which terminates HTTPS and serves cached or static content.
-
Dynamic requests are proxied to Apache, which runs the application and applies any
.htaccessrules.
Set it up
Choose Apache as the host's web server by setting webserver: apache2 - see
Configure Apache. TurboStack wires Nginx in front of Apache for you; there is no
proxy configuration to write by hand.
What you configure where
Important
Because Nginx (and Varnish) sit in front, the visitor's IP reaches Apache in the X-Forwarded-For
header. IP-based rules in .htaccess must read that header behind Varnish - see
Use .htaccess overrides.
When to choose this setup
Choose Apache when your application depends on .htaccess rules that it ships and maintains itself.
If you do not need .htaccess, Nginx alone (webserver: nginx) is the lighter default - see
Configure Nginx.