Omnikit
DevFilesMoneyAll tools
Ctrl K
Dev toolsFile toolsMoney calculatorsAll tools
HomeDeveloper toolsNginx Config GeneratorNginx Config for React, Vue and Angular Apps

Nginx Config for React, Vue and Angular Apps

dev

Serve a single-page app with nginx: every route to index.html, hashed assets cached

Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 22 Oct 2026.

A single-page app gives 404 on refresh because nginx looks for a file at /dashboard that does not exist. The fix is try_files $uri $uri/ /index.html, which sends every unknown path to the app. This config adds it, keeps index.html uncached so a new deploy shows at once, caches hashed assets for a year, and refuses hidden files such as .env and .git.

Next:
  • .htaccess Redirect Generator Paste old and new URLs and get 301 rules for .htaccess or Nginx, checked for loops

How to use Nginx Config for React, Vue and Angular Apps

1

Set the options you need, or start from the example.

2

The result is made again every time you change something.

3

Copy it or download it. Nothing was sent anywhere.

How Nginx Config for React, Vue and Angular Apps works

Most nginx configurations are copied from an answer written for another version and another job. This generator writes the whole file for yours, with a comment on every block, and leaves out the mistakes that are easy to copy.

Preset What it writes
Reverse proxy proxy_pass to your app with Host, X-Real-IP and X-Forwarded headers, an upload limit, optional WebSocket upgrades
Static site root and index, try_files with a real 404, assets cached for 30 days
Single-page app every route to index.html, index.html never cached, hashed assets cached for a year
Redirect domain every address of the old domain to the new one in one hop, path kept or dropped

The nginx traps it avoids. An add_header inside a location silently drops every header of the server block, so the security headers are written once and caching uses expires instead. text/html is always compressed, so listing it in gzip_types only adds a warning. HTTP/2 is switched on with http2 on in nginx 1.25.1 and later; turn off the version switch for the older listen form.

The rest of the article, and all 6 questions about Nginx Config Generator, are on the Nginx Config Generator page.

Frequently asked questions

How do I set up nginx as a reverse proxy for a Node app?

Choose Reverse proxy, type your domain and the address the app listens on, such as http://127.0.0.1:3000. The config forwards every request with the Host and X-Forwarded headers, so the app sees the real domain, visitor address and https. Turn on WebSocket if the app uses them.

Why does my React or Vue app give 404 on refresh?

Nginx looks for a file matching the address, such as /settings, and finds none. The Single-page app preset adds try_files $uri $uri/ /index.html, which serves index.html for every path that is not a real file, so the app's router can show the right page.

Why are my security headers missing on some pages?

In nginx, an add_header inside a location block replaces every add_header from the server block, it does not add to them. That is why this config writes the headers once at server level and uses the expires directive for caching, which sets Cache-Control without add_header.

Do I need a certificate before using the HTTPS config?

Yes, nginx will not start with a missing certificate file. Load only the HTTP server block first, run certbot certonly --webroot -w /var/www/letsencrypt with your domain, then add the HTTPS blocks. The default paths are the ones certbot writes under /etc/letsencrypt/live.

Sources

  • nginx, ngx_http_v2_moduleThe http2 directive, which appeared in 1.25.1, and the older listen ... http2 parameter
  • nginx, ngx_http_gzip_modulegzip_types: responses with the text/html type are always compressed
  • nginx, ngx_http_headers_moduleadd_header ... always, its inheritance rule, and expires
  • nginx, ngx_http_proxy_moduleproxy_pass with and without a URI, proxy_set_header, proxy_http_version
  • nginx, WebSocket proxyingThe map of $http_upgrade to $connection_upgrade and the Upgrade and Connection headers
  • Mozilla SSL Configuration Generator, intermediate profileTLS 1.2 and 1.3, session cache and timeout, session tickets off

Last verified 22 October 2026.

Rates and rules change; check the source before you rely on a figure.

Still stuck? Ask about Nginx Config Generator and anybody who knows can answer. No account needed.

More ways to use Nginx Config Generator

  • Nginx Config GeneratorA commented nginx server block for a reverse proxy, static site, SPA or redirect
  • Nginx Reverse Proxy Config GeneratorPut nginx in front of a Node, Python or Docker app, with HTTPS and WebSocket support

Same job, other tools: Sitemap Index Generator – Split a large site into numbered sitemaps with an index file.

On the related tools: Cron Expression Generator – Generate a cron expression by choosing when the job should run · Google Analytics URL Builder – The five utm parameters GA4 reads, with the naming traps flagged.

Related tools

All developer tools
UUID GeneratorRandom v4 and time-ordered v7 UUIDs, up to 1,000 at once, plus a validatorHash GeneratorMD5, SHA-1, SHA-256, SHA-384 and SHA-512 of text or files, with checksum compareCron Expression BuilderBuild a cron schedule from menus, read it in plain English, see the next runsSlug GeneratorClean URL slugs from titles, including accented and Hindi text, one or hundreds at onceMeta Tag GeneratorWrite title, description, canonical, Open Graph and Twitter tags with a live previewRobots.txt GeneratorBuild a robots.txt with presets, then check what every line really doesSitemap GeneratorTurn a list of URLs into a valid sitemap.xml, with an index when it gets too bigUTM BuilderBuild campaign links with source, medium and campaign, then export the lot as CSV
Was this tool helpful?
Omnikit

Small jobs, done in your browser. Free, fast and private. Files are never uploaded.

Files

  • Compress Image
  • Image to PDF
  • Merge PDF
  • Compress PDF
  • PDF to Word
  • Word to PDF

Dev

  • JSON Formatter & Validator
  • Base64 Encode & Decode
  • JWT Decoder, Verifier & Encoder
  • Password Generator
  • UUID Generator
  • Unix Timestamp Converter

Money

  • SIP Calculator
  • EMI Calculator
  • GST Calculator
  • FD Calculator
  • PPF Calculator
  • Lumpsum Calculator
GuidesQuestionsAboutHow we checkLaw library (beta)PrivacyTermsDisclosureContactMore: Exam practice (UGC NET Paper 1)Runs in your browser. Nothing is uploaded. © 2026 Omnikit (theomnikit.com)