With PHP-FPM, Nginx sends requests to a pool of processes via FastCGI. With Laravel Rust, the backend is a persistent HTTP binary: the proxy forwards requests to that process, which listens on 127.0.0.1:8000 by default. This difference changes the server configuration and deployment as well: updating files and reloading PHP-FPM is no longer enough.
Laravel Rust is built on Axum and Tokio and is still in beta; Laravel warns that versions before 1.0 may still have changes to their APIs and configuration. To create an application, Laravel News documents the requirements of Rust 1.99 or later, Node.js, and Git, along with these commands:
laravel new example-app --rust
cd example-app
laravel migrate
laravel dev
The development command starts the application, the queue worker, and the frontend development server. In production, the web process runs as a binary and the proxy keeps it behind the local address. The flow looks like this:
flowchart LR
A["Browser"] --> B["Nginx or Caddy"]
B -->|"Existing file"| C["public/ on disk"]
B -->|"No file"| D["Laravel Rust at 127.0.0.1:8000"]Nginx: serve files and forward everything else
A typical PHP-FPM configuration has a FastCGI route for index.php and rules for PHP files. With Rust, FastCGI is removed and an HTTP proxy is used. This block serves existing files from public/ and sends other routes to the application:
server {
listen 80;
listen [::]:80;
server_name example.com;
root /var/www/example.com/public;
location / {
try_files $uri @app;
}
location @app {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
The Host header is not decorative: without it, Nginx forwards the destination URL's host by default, and the application may receive 127.0.0.1:8000. In production, Laravel Rust responds to the hosts in APP_URL and their subdomains; a different host may receive a 400. Configure example.com and the application URL with the actual domain.
Nginx retains responsibility for static files, such as files in public/build/ and favicon.ico. The binary can also serve files from public/ if a route does not match, so forwarding everything is possible; keeping try_files lets Nginx serve the files directly. TLS termination is configured as in your existing PHP deployment.
Caddy: the same separation with fewer directives
In Caddy, the @app not file matcher identifies requests whose file does not exist in the root directory. reverse_proxy sends those requests to the binary; file_server handles available files:
example.com {
root * /var/www/example.com/public
encode zstd gzip
@app not file
reverse_proxy @app 127.0.0.1:8000
file_server
}
Caddy also lets you forward all requests without separating files from routes:
example.com {
reverse_proxy 127.0.0.1:8000
}
With direct proxying, the binary itself serves files from public/. Caddy passes through the original Host and sets X-Forwarded-For and X-Forwarded-Proto; it also discards an X-Forwarded-For sent by the client if trust has not been configured for that client. With Nginx, by contrast, you must define Host and the forwarded headers as in the block above.
Trusting the proxy in the application
Behind a proxy, the connection seen by the application comes from Nginx or Caddy. Without additional configuration, it may log the proxy's IP and consider a request that arrived over HTTPS insecure. Laravel Rust documents proxy trust in the middleware; the trusted address must be that of the proxy, not a wildcard:
.with_middleware(|middleware, _| {
middleware.trust_proxies(["127.0.0.1"]);
// ...
})
Add this line to src/app.rs and recompile the binary. The example assumes the proxy connects from 127.0.0.1; if your proxy uses another address, you must trust that address or range. With Nginx, $proxy_add_x_forwarded_for adds the client's IP to the received header. The application scans X-Forwarded-For from right to left and selects the first address it does not trust.
This setting affects the visitor's IP, the request's secure status, and generated URLs. Trusting only the proxy you control prevents blindly accepting an address the client may have spoofed in X-Forwarded-For. Trust is configured in the application independently of the frontend server.
Starting the binary with systemd
PHP-FPM is usually installed as a service through the system package manager. The Rust binary, by contrast, needs its own service. It also looks for public/, storage/, resources/, and .env in the directory it starts from; therefore, WorkingDirectory must point to the project root.
[Unit]
Description=example.com (Laravel Rust)
After=network.target
[Service]
User=www-data
WorkingDirectory=/var/www/example.com
ExecStart=/var/www/example.com/example-app
Restart=always
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target The open-file limit deserves attention: systemd defaults to 1024, while the server accepts 8192 connections by default. Each connection uses a file descriptor; running out can result in errors such as “unable to open database file.” LimitNOFILE raises the service limit.
If you cannot start from the project root, the configuration can use APP_BASE_PATH as an environment variable in the unit. Do not put it in .env to resolve the location of that same file: the application looks for .env in its starting directory.
Concurrency: connections, databases, and CPU-bound work
PHP-FPM limits simultaneous requests with pm.max_children: each PHP process handles one request at a time. Laravel Rust uses Tokio; its threads can handle other requests while one is waiting for the database, Redis, or an HTTP call. The connection limit is not the database pool limit: they are separate controls.
# Example values for the Laravel Rust environment
TOKIO_WORKER_THREADS=4
SERVER_MAX_CONNECTIONS=8192
DB_MAX_CONNECTIONS=10
Tokio defaults to one thread per CPU core, and SERVER_MAX_CONNECTIONS is 8192 open connections for the process. The database pool starts with 10 connections; when they are busy, the next query waits up to 30 seconds. Before increasing it, count the connections across all instances and compare that number with the database limit.
A CPU-intensive handler, such as an image-processing task or a large export, does not behave like a query waiting on the network. Intensive work can block an execution thread; Laravel documents task::spawn_blocking to move it to a separate thread pool. By contrast, a single process can already use the available cores: you do not need multiple copies just to distribute requests.
Deploying: compile, migrate, and restart
With PHP, updating usually involves installing dependencies and reloading PHP-FPM. With Rust, the code is inside the binary: each release requires compiling and restarting the service. This workflow reproduces the published deployment commands for an application with a Vite frontend:
cd /var/www/example.com
git pull
cargo build --release
npm ci && npm run build
cp target/release/example-app example-app.new
mv example-app.new example-app
./example-app migrate --force
sudo systemctl restart example-app example-app-queue
The new binary is first copied under a different name and then renamed. Copying it directly over the executable that is still in use can fail with “Text file busy”; renaming lets you replace the file while the active process retains the old binary until it restarts.
Compile on a system compatible with the server: the executable depends on the glibc version of the system where it was built. For example, a build on Debian 12 may fail on Ubuntu 20.04 because it requires GLIBC_2.34. If you compile in continuous integration, use the same operating system version as the server.
The restart also creates an interruption window: when it receives SIGTERM, the application stops accepting connections and waits up to 20 seconds for active requests to finish. While the new process is not yet listening, Nginx may return 502. To avoid this interval, the described alternative is to run two instances on different ports behind the proxy and restart them one at a time.
Configuration issues worth checking
If the host does not match, check APP_URL and the Host header received by the application. If the logged IPs are those of the proxy or URLs use http:// after enabling TLS, check the forwarded headers and the trusted proxy list. These are two separate settings: proxy and middleware, and both must match the actual topology.
There are also limits outside the binary. Nginx limits uploads to 1 MB by default, while Laravel Rust accepts multipart uploads up to 16 MB; a 2 MB request may receive a 413 before reaching the application. Adjust client_max_body_size if you need to allow larger uploads. Caddy has no limit by default.
Finally, static files served directly by Nginx or Caddy do not receive the security headers Laravel Rust adds to its responses. The binary also does not set Cache-Control for public/build/. Check headers and caching for static files if the proxy serves them from disk; dynamic responses and static files do not follow exactly the same path.
The main change is easy to summarize: HTTP takes the place of FastCGI, and a long-running service takes the place of PHP-FPM. In return, deployment requires compiling, taking care with the working directory, and restarting the process; the beta may change its APIs and configuration, so it is worth validating each update before putting it on the server.
Sources: ma.ttias.be, Laravel, Laravel News, Laravel