How I build a basic nginx config without starting from an empty file
· 2 min read
An nginx config is easier to write when I start from the kind of site I am serving: static files, SPA, PHP, or reverse proxy.
The nginx Config Generator tool helps me inspect the input and output without writing a one-off script first.
The simple idea
An nginx config is easier to write when I start from the kind of site I am serving: static files, SPA, PHP, or reverse proxy.
I use it to answer one focused question at a time, then I review the result before using it anywhere important.
Step 1: Choose the site type
Choose the site type.
Step 2: Enter the domain name
Enter the domain name.
Step 3: Set the document root or upstream app
Set the document root or upstream app.
Step 4: Choose index and fallback behaviour
Choose index and fallback behaviour.
Step 5: Add TLS or redirect assumptions carefully
Add TLS or redirect assumptions carefully.
Step 6: Generate the config and read it before using it
Generate the config and read it before using it.
Step 7: Run nginx -t before reloading nginx
Run nginx -t before reloading nginx.
My checklist
Before I trust the result, I check:
- Choose the site type.
- Enter the domain name.
- Set the document root or upstream app.
- Choose index and fallback behaviour.
- Add TLS or redirect assumptions carefully.
- Generate the config and read it before using it.
- Run
nginx -tbefore reloading nginx.
The tool makes the mechanical part faster. The decision still belongs to me: is this result correct, safe, and appropriate for the real task?
Comments
Comments are welcome — please read the comment policy first. Powered by giscus and GitHub Discussions.