Serves static files and passes PHP to FPM. Every PHP project has one — Drupal,
Laravel, WordPress or plain PHP. A Node.js, Go, Python, Ruby or Rust project has
one only where its vallic.yaml names it, because the application answers HTTP
itself (see In front of an application below),
and a static site is nginx and nothing else.
What it serves is decided by your project type, not by a setting:
| Project | Document root | Configuration |
|---|---|---|
| Drupal | web/ |
Drupal 11's, or Drupal 10's when runtime.drupal is '10' |
| Laravel | public/ |
Laravel's |
| WordPress | the repository root | WordPress's |
| PHP | public/ |
a plain PHP one |
| Node.js, Go, Python, Django, Ruby, Rust | public/ |
files from there, every other path to the application |
The code is mounted read-only; uploads are served from the files directory that outlives the release. In front of Nginx is the platform's proxy, which terminates TLS and routes the hostname — or Vinyl Cache (Varnish), when the stack runs it.
Paths under /.well-known/ reach your application, as every other path does:
a discovery document, OpenID's configuration or WebFinger is answered by the
route your application declares. A file of that name in the document root is
served as a file instead.
So do /llms.txt and /llms-full.txt, and /robots.txt, /humans.txt
and /ads.txt: a module or plugin that generates them (Drupal's RobotsTxt,
WordPress's own robots.txt) answers there, and a file of that name in the
document root is served as a file instead.
A slow request passes through Nginx before it reaches PHP, and whichever gives
up first answers. Raise NGINX_FASTCGI_READ_TIMEOUT together with
PHP_MAX_EXECUTION_TIME — see Service settings.
In front of an application
A Node.js, Go, Python, Ruby or Rust application is its own server and gets no Nginx unless its repository names one:
services:
- nginx: '1.31'
Then Nginx answers first. A file in the release's public/ is served from
disk without reaching your application — the compiled assets, the images — and
every other path goes on to it, on the port it listens on, over HTTP/1.1 with
WebSockets passed through. Your application sees the scheme and the client's
address the platform's proxy saw (X-Forwarded-Proto, X-Forwarded-For) and
the hostname that was asked for. A path under /.well-known/, /llms.txt,
/robots.txt, /humans.txt or /ads.txt, or one ending in .mp4, .mov,
.m4a or .flv, with no file behind it reaches your application too.
Nginx answers /favicon.ico itself, from public/ alone, with an empty image
where there is no file. An application that writes it at request time writes
it into public/ at its build instead.
NGINX_CLIENT_MAX_BODY_SIZE is the largest request Nginx passes on, 32 MB
unless you raise it, and Vinyl Cache, where the stack runs
it, asks Nginx rather than the application.
Rules of your own
Two files in your repository add to Nginx's configuration rather than replacing it, on a PHP project, a static site, or Nginx in front of an application:
| File | Added to |
|---|---|
.vallic/nginx/server.conf |
the site's server block, after the platform's: a location of your own, a redirect, a header |
.vallic/nginx/http.conf |
the http block, for what Nginx allows only there and a location names: a proxy_cache_path, an upstream, a map, a limit_req_zone |
A week's cache of the thumbnails an application makes, and an old address sent on:
# .vallic/nginx/http.conf
proxy_cache_path /var/cache/nginx/thumbnails levels=1:2 keys_zone=thumbnails:10m max_size=1g inactive=7d use_temp_path=off;
# .vallic/nginx/server.conf
location ^~ /thumbnails/ {
proxy_cache thumbnails;
proxy_cache_valid 200 7d;
proxy_cache_use_stale error timeout updating;
proxy_set_header Host $http_host;
proxy_pass http://app_server;
}
location = /old-pricing {
return 301 /pricing;
}
In front of an application, app_server is your application and @app the
location that passes a request on to it, the scheme and the client's address
included; on a PHP project, php is PHP-FPM. /var/cache/nginx is Nginx's
to write, and starts empty when Nginx is restarted.
Your locations come after the platform's. One with = or ^~ answers for its
paths ahead of the platform's regular expressions; a regular expression of
yours is tried after the platform's, so one of theirs that matches first
answers. A location the platform already has, location / among them, is
refused by Nginx as a duplicate: name a more specific one.
Each file is read from the commit of the release you deployed, so a change
takes effect with the deploy that carries it, not when you push, and a
rollback brings back the rules of the release you roll back to. Each is at
most 8 KB. A file may not include another file or load a module, and
http.conf may not declare a server: the site's server is the platform's,
and server.conf is added inside it, so it holds locations and directives
rather than a block around them. A file that does is left out, and Nginx
runs without it.
Before Nginx reads them, the machine asks Nginx (nginx -t). Rules it refuses
are not loaded: Nginx keeps the rules that last passed, and Web server
rules on the environment's Resources tab says what Nginx said, the file and
the line with it. Where Nginx would start from a new definition, a new version
or new settings, that refuses your rules, nothing of the change is made until
the rule is fixed.
Versions
| Version | Status |
|---|---|
1.31 |
Supported, and the default |
1.30 |
Supported |
Pin the version, not the build: name 1.31 and the platform matches it to the
current build, so a security rebuild reaches you without anybody editing a
repository.
What you can change
In vallic.yaml — what each one does is on Service settings:
services:
- nginx:
version: '1.31'
environment:
NGINX_CLIENT_MAX_BODY_SIZE: …
NGINX_KEEPALIVE_TIMEOUT: …
NGINX_FASTCGI_READ_TIMEOUT: …
NGINX_GZIP_COMP_LEVEL: …
NGINX_STATIC_EXPIRES: …
NGINX_ERROR_LOG_LEVEL: …
NGINX_DRUPAL_NOT_FOUND_REGEX: …
NGINX_WP_NOT_FOUND_REGEX: …
Anything not on this list refuses the deploy, naming the variable — rather than being accepted and quietly ignored.
Thank you. Good to know it helped.
Thanks — tell us what was missing. Open a ticket from Support in the console, and we answer on the ticket. Open the console