Server Type
Reverse Proxy
Forward requests to a backend app (e.g. Node, Python)
Static Server
Serve frontend files (React, Vue, HTML)
Load Balancer
Distribute traffic across multiple backends
The NGINX SPA Routing Generator creates static asset servers optimized for React, Vue, and Angular applications. It instantly solves the infamous '404 Page Not Found' error on page refresh by routing all requests to index.html.
Configures try_files to natively support React Router.
Injects aggressive browser caching headers for JS/CSS files.
Set Web Root - Define the directory where your built assets live (e.g. `/usr/share/nginx/html`).
Configure Caching - Enable browser caching for static assets.
Generate Config - Download the SPA-optimized server block.
SPA routing requires an explicit fallback mechanism using the try_files directive.
$uri $uri/ =404 (Returns error)
$uri $uri/ /index.html (Boots React)
None (Slow loads)
max-age=31536000 for static assets
Here is a real generated snippet matching the production best practices above:
server {
listen 80;
server_name app.example.com;
root /usr/share/nginx/html;
index index.html;
# SPA Routing Fallback
location / {
try_files $uri $uri/ /index.html;
}
# Aggressive Caching for Static Assets
location ~* \.(?:css|js|jpg|svg|woff2)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
}Technical troubleshooting and advanced configuration insights for your infrastructure.
Scroll back up to the generator and export your production-ready configuration in seconds.
Start Building