Exponential has no nginx configuration of its own in the kernel. The example doc/eng-us/examples/web-servers/nginx.conf translates .htaccess_root into nginx directives, rule for rule, and adds HTTPS, HTTP/2, a port 80 redirect and the security headers. nginx never reads .htaccess, so exp:setup:htaccess does not protect an nginx site: these rules do.
Install it
- Copy the file to /etc/nginx/conf.d/example.com.conf. It is read inside the http {} block, because it holds map blocks as well as server blocks.
- Replace example.com, /var/www/example.com, the PHP-FPM socket (it appears five times) and the certificate paths.
- Create the PHP-FPM pool. nginx's user must be able to open its socket.
- Get the certificate; the port 80 server serves /.well-known/acme-challenge/ for it.
- Check and reload: nginx -t, then systemctl reload nginx.
http2 on; needs nginx 1.25.1 or later. On older versions write listen 443 ssl http2; instead.
Why the order matters
nginx chooses a location by its own precedence, not by file order: exact matches first, then the longest ^~ prefix, then regular expressions in the order they appear, then the longest plain prefix. The dot-path and script rules are therefore the first regular expressions, and location / catches the rest, like the final rule of .htaccess_root.
- The front controllers are named in SCRIPT_FILENAME and the request is not rewritten, so REQUEST_URI still carries the address the visitor asked for.
- The static locations have no fastcgi_pass, so no PHP runs there.
- settings/, var/log/, vendor/, kernel/ and composer.json reach location / and are answered by index.php, never sent.
- The SOAP location is commented out because SOAP is off by default. Its entry script is index_soap.php since 6.0.15.
Behind a proxy or load balancer
When TLS ends at a load balancer in front of nginx, keep one server block on the port the balancer talks to. nginx passes X-Forwarded-Proto to PHP, but the kernel believes it only from an address listed in site.ini [HTTPHeaderSettings] TrustedProxies[].
config.php
The console still helps on nginx: ./console exp:setup:config --apply puts config.php into place.