Nginx Config Generator
Generate an Nginx server block for Laravel with PHP-FPM, a Node or Go reverse proxy, a single-page app or a static site, with HTTPS, redirects and gzip.
Free · No sign-up · Your inputs stay in your browser
Input
Generate an Nginx server block
Output
server block
1,845 characters
Uses the http2 on; directive from Nginx 1.25.1; on older versions write listen 443 ssl http2; instead. The Laravel block follows the deployment page of the Laravel docs, including $realpath_root, which keeps symlinked zero-downtime releases from serving the previous release. Test with nginx -t before reloading.
Runs in this browser. Nothing you paste is sent to a server.
About this tool
Method, assumptions, practical next steps, and limits.
The Laravel block
It follows the Nginx configuration in Laravel's deployment docs: the root is public/, every request that is not a file goes to index.php, and only that one PHP file is passed to FastCGI. Using $realpath_root rather than $document_root matters for zero-downtime deploys that switch a current symlink, because it resolves the link and lets PHP's opcache see the new release.
Reverse proxies
An app behind Nginx sees every request coming from 127.0.0.1 unless Nginx passes the client's details in X-Forwarded-For and X-Forwarded-Proto and the app is told to trust them. WebSockets need the Upgrade and Connection headers forwarded, which the map block at the top sets up, as described in Nginx's WebSocket proxying page.
Before reloading
Run sudo nginx -t and only then sudo systemctl reload nginx. A reload with a broken file is refused and the old configuration keeps running; a restart with one takes the site down.