The routing is the block of locations that decides what serves each URL of the site: a front
controller, an SPA's client-side routes, real 404 pages, a proxied /api, redirects. It is the only
part of the vhost you can edit. TLS, certificates, logs, limits, the page cache and its bypass rules,
the security headers and the PHP-FPM link stay the panel's.
Open the editor
- Open the site.
- Open More and choose Vhost. Only administrators have it.
The Routing and vhost tab shows the panel's part of the vhost read-only, above and below the editor. The editor holds the current routing: at first, the site type's default.
| Site type | Default routing |
|---|---|
| WordPress, WooCommerce, PHP, Laravel | location / { try_files $uri $uri/ /index.php?$args; } |
| Static | location / { try_files $uri $uri/ /index.html =404; } |
| Reverse proxy | location / with proxy_pass to the upstream, the Host, X-Real-IP, X-Forwarded-For and X-Forwarded-Proto headers, websockets and a 60 s read timeout |
Change the routing
- Write the blocks in the editor.
- Choose Save.
The panel checks the block against its rules, then writes the vhost and has nginx test the
configuration (nginx -t). When nginx accepts it, the panel reloads it and shows Routing saved and
live. When nginx refuses it, the panel puts the previous files back, shows the error with the
block's line, and the site keeps serving with its previous routing.
For example, the routing of an SPA that also has an API served by its app on port 3000:
location / {
try_files $uri $uri/ /index.html =404;
}
location /api/ {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
}
Go back to the default routing
Choose Restore default and confirm. The site type's routing replaces your blocks.
What the panel refuses
The block may serve only the site itself. The panel refuses, naming the line:
- directives outside its list: among others
include, logs, TLS, caching, scripting modules,fastcgi_passand every*_passother thanproxy_pass; rootandaliasoutside<site folder>/currentor<site folder>/releases/<name>, or on a hidden folder such as.git;- a
proxy_passto a Unix socket, with a variable, or to a system service's port on this machine or a private network (80, 443, 8443, 3306, 6379, 5252, 9080, and any listening port of a user that is not a site). The site's own app, started by its user, is reachable; - paths built from client values (
$args,$http_*,$cookie_*,$request_uri) and any..segment; cg_*variables, which belong to the panel's cache.
A location or if block that adds its own add_header still gets the panel's security headers.
A staging copy takes production's routing, with the root and alias paths moved to its own folder.