Skip to main content

Nginx Config Generator

Generate an Nginx server block for a reverse proxy, static site, single page app or PHP, with HTTPS, redirects, gzip and caching.

More options

nginx configuration

Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)

Free Online Nginx Config Generator

Choose what the server should do, enter your domain, and get an Nginx configuration you can paste and test. HTTPS, redirects and sensible defaults are included. It gives developers a quick browser-based way to solve a focused nginx config generator task before moving the result into a project.

How to generate a config

Pick a type (reverse proxy, static site, single page app or PHP), enter the domain and, for a proxy, the address of your app. Copy the result into your Nginx configuration.

Testing it

Run sudo nginx -t. It tells you if the file is valid before you reload the server.

Common mistakes

  • Forgetting the semicolon at the end of a directive: Nginx refuses to start and names the line.
  • Pointing proxy_pass at a port the app does not listen on, which gives a 502 Bad Gateway.

Frequently asked questions

Where does the file go?
Save it in /etc/nginx/conf.d/example.conf or /etc/nginx/sites-available/ (and link it in sites-enabled), then run nginx -t to test and systemctl reload nginx.
Where do the HTTPS certificates come from?
The paths match what Certbot (Let's Encrypt) creates under /etc/letsencrypt/live/<domain>/. Run certbot first, or change the two paths to your own certificate files.
What is the single page app preset?
It serves index.html for any address that is not a real file, which React, Vue and Angular apps with client-side routing need.
Should I turn on HSTS?
Only when you are sure HTTPS works for the whole site. HSTS tells browsers to refuse plain HTTP for a year, so a mistake is hard to undo.
How do I use this nginx config generator tool?
Use the interactive controls above; processing stays in your browser and the result is intended as a practical starting point for development work.

More DevOps & Network

View all DevOps & Network tools →