Nginx Config Generator
Simple toggles se ek complete nginx server block banayein, live apne browser mein. Aapke inputs aapke device par hi rehte hain.
Aapka domain, paths, aur certificate locations sirf aapke browser mein config banane ke liye use hote hain, jo kabhi upload nahi hota. Phir bhi, kisi bhi tool mein asli private-key contents paste karne se bachein.
Apne web root ke liye file permissions chahiye? Chmod Calculator try karein.
Nginx Config Generator ke baare mein
Yeh nginx config generator kuch inputs aur toggles ko ek complete, valid nginx server block mein badal deta hai jise aap sites-available mein daal sakein. Ek static site (root + index with try_files) ya ek reverse proxy (proxy_pass with standard Host, X-Real-IP, X-Forwarded-For, aur X-Forwarded-Proto headers, plus optional WebSocket upgrade lines) chunein. SSL on karein taaki 443 par listen ho, ssl_certificate aur ssl_certificate_key wire up karein, aur ek doosra server block emit karein jo HTTP ko HTTPS par 301-redirect karta hai. gzip, long-lived static asset caching, ek client_max_body_size limit, aur ek canonical www-to-non-www redirect har ek ek click mein add karein. Ek nginx config generator ke roop mein yeh braces balanced aur indentation clean rakhta hai, phir aapko result copy karne ya use <domain>.conf ke roop mein download karne deta hai. Sab kuch aapke browser mein chalta hai, isliye aapka domain aur paths aapke device par hi rehte hain.
Features
- Static site mode root, index, aur ek try_files location block ke saath
- Reverse proxy mode proxy_pass aur standard proxy_set_header lines ke saath
- proxy_http_version, Upgrade, aur Connection headers ke zariye optional WebSocket support
- SSL toggle jo listen 443 ssl plus ek HTTP→HTTPS 301 redirect server add karta hai
- text, JSON, JavaScript, CSS, XML, aur SVG ke liye tuned gzip block
- expires aur immutable Cache-Control ke saath static asset caching location
- client_max_body_size input aur www↔non-www canonical redirects
- Server block copy karein ya use example.com.conf ke roop mein download karein
Nginx Config Generator kaise use karein
- Apna domain aur listen port enter karein, aur static site ya reverse proxy chunein.
- Apne app ke liye root aur index, ya proxy_pass upstream bharein.
- Zaroorat ke hisaab se SSL, gzip, caching, body size, aur ek www redirect toggle karein.
- Right side par live nginx config padhein, phir .conf Copy ya Download karein.
Example
Input
Domain: example.com
Mode: Reverse proxy
Upstream: http://127.0.0.1:3000
SSL: on
Output
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name example.com www.example.com;
ssl_certificate /etc/ssl/certs/example.com.crt;
ssl_certificate_key /etc/ssl/private/example.com.key;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com;
return 301 https://$host$request_uri;
}
443 par ek reverse proxy uske matching HTTP→HTTPS redirect block ke saath.
Common errors aur troubleshooting
- nginx -t "cannot load certificate" report karta hai ya SSL block start nahi hota. — ssl_certificate ko apni fullchain file par aur ssl_certificate_key ko matching private key par point karein, aur sunishchit karein ki dono paths maujood hain aur nginx ke liye readable hain.
- Ek reverse-proxied app galat client IP dikhata hai ya HTTPS ke peeche toot jaata hai. — Generated proxy_set_header lines rakhein taaki Host, X-Real-IP, X-Forwarded-For, aur X-Forwarded-Proto aapke upstream tak pahunchein, aur unhe apne app mein sahi headers se padhein.
- WebSocket connections ek 400 ke saath drop hote hain ya upgrade nahi hote. — WebSocket support on karein taaki location proxy_http_version 1.1 with Upgrade aur Connection "upgrade" headers add kare jo nginx ko ws/wss proxy karne ke liye chahiye.
- Bade uploads 413 Request Entity Too Large return karte hain. — client_max_body_size ko apne sabse bade upload se upar ki value par set karein, jaise 20M ya 100M, aur nginx reload karein.
Aksar pooche jaane wale sawaal
- nginx mein reverse proxy kaise set up karoon?
- Reverse proxy chunein, proxy_pass mein apna upstream enter karein (jaise http://127.0.0.1:3000), aur generator standard Host, X-Real-IP, X-Forwarded-For, aur X-Forwarded-Proto headers ke saath ek location / block add karta hai. Agar aapka app ws/wss use karta hai to WebSocket support enable karein.
- nginx server blocks kahan rehte hain?
- Debian aur Ubuntu par, generated file ko /etc/nginx/sites-available/example.com ke roop mein save karein aur use sites-enabled mein symlink karein. Kai doosre distros par, use /etc/nginx/conf.d/example.com.conf mein daalein, phir nginx -t chalayein aur reload karein.
- SSL toggle config ko kaise badalta hai?
- Yeh main server ko 443 ssl par listen karne par switch karta hai, ssl_certificate aur ssl_certificate_key add karta hai, aur port 80 par ek doosra server block emit karta hai jo har request ko https:// par 301-redirect karta hai, taaki visitors hamesha secure site par land karein.
- Yahan static site aur reverse proxy mein kya farak hai?
- Static mode index aur ek try_files location ke saath ek root directory se files serve karta hai, HTML, SPAs, ya built assets ke liye ideal. Reverse proxy mode files serve karne ke bajaye proxy_pass aur proxy headers ke saath requests ko ek upstream app server par forward karta hai.
- Kya main gzip aur static asset caching add kar sakta hoon?
- Haan. gzip toggle text, JSON, JavaScript, CSS, XML, aur SVG ke liye ek tuned gzip block add karta hai, aur caching toggle ek location add karta hai jo common asset extensions ke liye 30-day expires aur ek immutable Cache-Control header set karti hai.
- Kya mera domain ya config kahin bheja jaata hai?
- Nahi. Yeh nginx config generator poori tarah aapke browser mein chalta hai, isliye jo domain, paths, aur certificate locations aap type karte hain woh aapke device par process hote hain aur generated file kabhi upload nahi hoti.
Related tools
Saare ArrayKit tools