Server Config Generator — Free Online Tool

Generate server configuration files: Apache .htaccess, Nginx conf, Node.js server, Express.js. HTTPS, redirects, caching, security headers, CORS.

Use this free online Server Config Generator directly in your browser. No signup required, no data leaves your device. Part of Utilier — a collection of 133+ developer utilities.

What is Server Configuration Generator (Apache, Nginx, Node.js)?

Server configuration generator creates configuration files for web servers (Apache, Nginx) and Node.js applications. Generate Apache .htaccess (redirects, rewrites, caching, security), Nginx server blocks (virtual hosts, reverse proxy, SSL), or Node.js/Express.js boilerplate (routing, middleware, CORS). Customize settings: HTTPS redirect (HTTP → HTTPS), www redirect (www → non-www), caching headers (Cache-Control, Expires), security headers (CSP, HSTS, X-Frame-Options), GZIP compression, CORS, rate limiting. Copy-paste ready configuration for production deployment.

Server configuration turns an application into a reachable, secure service by defining hostnames, ports, static-file rules, reverse proxies, TLS behavior, headers, and request limits. Apache, Nginx, and Node.js express these concerns differently, so generated configuration is a starting point that must be adjusted for the deployment environment, certificate paths, upstream ports, and operational requirements.

  • Apache .htaccess: Generate .htaccess rules: redirects (301, 302), URL rewrites (remove .php, trailing slash), caching (images, CSS, JS), security (disable directory listing, block bad bots), HTTPS enforcement.
  • Nginx configuration: Generate Nginx server blocks: virtual hosts (domain routing), reverse proxy (Node.js, Python), SSL/TLS (Let's Encrypt), caching, GZIP, security headers.
  • Node.js/Express.js: Generate Express.js boilerplate: basic server, routing, middleware (body-parser, CORS, helmet), static files, error handling, HTTPS setup.
  • HTTPS and security: HTTPS redirect (HTTP → HTTPS), HSTS header (force HTTPS), CSP (Content Security Policy), X-Frame-Options (prevent clickjacking), X-Content-Type-Options (prevent MIME sniffing).
  • Caching and performance: Cache-Control headers (images, CSS, JS), GZIP compression, Brotli, expires headers. Improves page speed and reduces bandwidth.

Why use server config?

Writing server configuration manually is error-prone (syntax errors, security misconfigurations, performance issues). This tool generates production-ready configs.

  • Avoid syntax errors: Apache and Nginx configs are sensitive to syntax errors (missing semicolons, wrong directives). Tool validates syntax and generates correct configs.
  • Security by default: Includes security headers (CSP, HSTS, X-Frame-Options), HTTPS enforcement, disable directory listing. Prevents common vulnerabilities.
  • SEO and performance: HTTPS redirect (SEO ranking factor), caching headers (page speed), GZIP compression (reduce bandwidth), redirects (301 for SEO).
  • Save time: No need to search docs for directive names or examples. Tool generates configs instantly based on your needs.
  • Learn best practices: See how to configure HTTPS, caching, security headers, reverse proxy. Great for learning server administration.
  • Copy-paste ready: Copy config to .htaccess, nginx.conf, or server.js. Deploy immediately without manual editing.

When to use server config

Use whenever you need to configure web servers or Node.js applications.

  • Setting up Apache .htaccess for redirects, rewrites, caching, or security.
  • Configuring Nginx for virtual hosts, reverse proxy, SSL, or static file serving.
  • Creating Node.js/Express.js server boilerplate for API or web app.
  • Enforcing HTTPS (HTTP → HTTPS redirect, HSTS header) for security and SEO.
  • Adding security headers (CSP, X-Frame-Options, X-Content-Type-Options) to prevent attacks.
  • Configuring caching (Cache-Control, Expires) to improve page speed.
  • Setting up CORS for API access from different domains.

How to use server config

Select server type, configure options, generate config.

  1. Choose server type: Select: Apache (.htaccess), Nginx (server block), Node.js/Express.js (server.js). Different syntax and features for each.
  2. Configure redirects (optional): HTTPS redirect (HTTP → HTTPS), www redirect (www.example.com → example.com or vice versa), 301/302 redirects (old URL → new URL).
  3. Set caching rules (optional): Cache static files (images, CSS, JS) with Cache-Control: max-age=31536000. Specify file types (.jpg, .css, .js) and expiration time (1 year, 1 month).
  4. Add security headers (optional): HSTS (enforce HTTPS), CSP (Content Security Policy), X-Frame-Options (prevent clickjacking), X-Content-Type-Options (prevent MIME sniffing).
  5. Enable GZIP compression (optional): Compress text files (HTML, CSS, JS, JSON) to reduce bandwidth. Improves page load speed.
  6. Configure CORS (optional, Nginx/Node.js): Allow cross-origin requests (Access-Control-Allow-Origin). Specify allowed origins (* or specific domain).
  7. Copy configuration: Click Copy to get config. Save as .htaccess (Apache root directory), nginx.conf (Nginx), or server.js (Node.js). Deploy to server.

Key features

  • Apache .htaccess: Redirects, rewrites, caching, security, HTTPS enforcement, disable directory listing.
  • Nginx configuration: Server blocks, reverse proxy, SSL/TLS, caching, GZIP, security headers.
  • Node.js/Express.js: Server boilerplate, routing, middleware (CORS, helmet), static files, error handling.
  • HTTPS redirect: HTTP → HTTPS (301 redirect). SEO ranking factor and security best practice.
  • Security headers: HSTS, CSP, X-Frame-Options, X-Content-Type-Options. Prevent clickjacking, XSS, MIME sniffing.
  • Caching rules: Cache-Control, Expires headers for static files. Improves page speed and reduces bandwidth.
  • GZIP compression: Compress text files (HTML, CSS, JS). Reduces file size by 70-80%.

Common use cases

  • Apache HTTPS redirect: .htaccess: RewriteEngine On, RewriteCond %{HTTPS} off, RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]. Redirects all HTTP to HTTPS (SEO and security).
  • Nginx reverse proxy (Node.js): Nginx proxies requests to Node.js app on port 3000. location / { proxy_pass http://localhost:3000; proxy_set_header Host $host; }. Used for production deployments.
  • Apache caching (1 year for images): .htaccess: <FilesMatch "\.(jpg|jpeg|png|gif|svg)
    quot;> Header set Cache-Control "max-age=31536000, public" </FilesMatch>. Browsers cache images for 1 year.
  • Nginx SSL/TLS (Let's Encrypt): Nginx: listen 443 ssl; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;. HTTPS with free SSL cert.
  • Express.js CORS: Node.js: app.use(cors({ origin: 'https://example.com' }));. Allows API requests from example.com (prevents CORS errors).
  • Apache security headers: .htaccess: Header set X-Frame-Options "SAMEORIGIN", Header set X-Content-Type-Options "nosniff", Header set Content-Security-Policy "default-src 'self'". Prevents clickjacking, MIME sniffing, XSS.

Examples

Server configuration examples.

Apache HTTPS redirect (HTTP → HTTPS)

Server: Apache, Option: HTTPS redirect
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

Redirects all HTTP traffic to HTTPS (301 permanent). SEO ranking factor. Add to .htaccess in root directory.

Nginx reverse proxy (Node.js on port 3000)

Server: Nginx, Option: Reverse proxy to localhost:3000
location / { proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;
}

Proxies requests to Node.js app. Nginx handles static files, proxies API to backend. Production setup.

Apache caching (images, 1 year)

Server: Apache, Option: Cache images for 1 year
<FilesMatch "\.(jpg|jpeg|png|gif|svg)
quot;> Header set Cache-Control "max-age=31536000, public" </FilesMatch>

Browsers cache images for 1 year (31536000 seconds). Reduces server load and improves page speed. Add to .htaccess.

Express.js server with CORS

Server: Node.js/Express.js, Option: Enable CORS
const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors());
app.get('/', (req, res) => res.send('Hello'));
app.listen(3000);

Express.js server with CORS enabled (allows cross-origin requests). Used for APIs accessed from different domains.

Nginx SSL/TLS (Let's Encrypt)

Server: Nginx, Option: HTTPS with Let's Encrypt
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

HTTPS with free SSL cert from Let's Encrypt. Add to Nginx server block. Replace example.com with your domain.

Technical reference

Server configuration specifications:

Apache .htaccess
Plain text file in website root. Controls: redirects (RewriteRule), rewrites, caching (Header set Cache-Control), security (Options -Indexes). Requires mod_rewrite enabled.
Nginx configuration
File in /etc/nginx/sites-available/. Server blocks define virtual hosts. Directives: listen (port), server_name (domain), location (routing), proxy_pass (reverse proxy), ssl_certificate (HTTPS).
Node.js/Express.js
JavaScript file (server.js, app.js). Uses Express framework: app.get (routing), app.use (middleware), app.listen (port). Middleware: body-parser, cors, helmet (security).
HTTPS redirect
Apache: RewriteCond %{HTTPS} off, RewriteRule. Nginx: if ($scheme != "https") { return 301 https://$host$request_uri; }. Node.js: middleware checks req.protocol.
Caching headers
Cache-Control: max-age=31536000 (1 year), public (cacheable by browsers/CDN). Expires: Thu, 31 Dec 2025 23:59:59 GMT (older syntax). ETag: file hash for validation.
Security headers
HSTS: Strict-Transport-Security: max-age=31536000 (force HTTPS). CSP: Content-Security-Policy: default-src 'self' (prevent XSS). X-Frame-Options: SAMEORIGIN (prevent clickjacking).
GZIP compression
Apache: mod_deflate. Nginx: gzip on; gzip_types text/css text/javascript. Node.js: compression middleware. Compresses HTML, CSS, JS, JSON (70-80% reduction).
CORS
Nginx: add_header Access-Control-Allow-Origin *; (or specific domain). Node.js: app.use(cors()). Allows cross-origin requests (API access from different domain).
Reverse proxy
Nginx: location / { proxy_pass http://localhost:3000; }. Routes requests to backend (Node.js, Python). Used for production (Nginx handles static files, proxies API to backend).
SSL/TLS
Nginx/Apache: ssl_certificate (fullchain.pem), ssl_certificate_key (privkey.pem). Let's Encrypt provides free SSL certs. Node.js: https.createServer({ key, cert }, app).

Common mistakes to avoid

Not enabling mod_rewrite for Apache .htaccess rewrites, causing 500 errors

Why it happens: .htaccess RewriteRule requires mod_rewrite Apache module. If not enabled, site returns 500 Internal Server Error. Common on shared hosting or new Apache installs.

How to avoid it: Enable mod_rewrite: sudo a2enmod rewrite, then restart Apache: sudo service apache2 restart. Also ensure AllowOverride All in Apache config (allows .htaccess to override settings).

Using HTTP → HTTPS redirect without updating internal links, causing mixed content

Why it happens: HTTPS redirect works, but internal links use http:// (e.g., <img src="http://example.com/image.jpg">). Browser blocks mixed content (HTTPS page loading HTTP resources). Broken images/CSS.

How to avoid it: Use relative URLs (/image.jpg) or protocol-relative (//example.com/image.jpg). Or update all links to https://. Check browser console for mixed content warnings.

Setting Cache-Control max-age too high for frequently updated files (HTML, API responses)

Why it happens: Example: Cache-Control: max-age=31536000 (1 year) for index.html. If you update HTML, users see cached old version for 1 year. Common mistake when copy-pasting cache rules.

How to avoid it: Use long cache (1 year) for static files (images, CSS, JS with version hashes). Use short cache (5 min) or no-cache for HTML, API responses. Example: Cache-Control: no-cache for HTML.

Not setting CORS headers, causing API requests to fail from different domains

Why it happens: Browser blocks cross-origin requests by default (CORS policy). Example: API on api.example.com, frontend on example.com. Requests fail with CORS error. Common when separating API and frontend.

How to avoid it: Add CORS headers: Access-Control-Allow-Origin: https://example.com (specific domain) or * (all domains). Nginx: add_header. Express.js: app.use(cors()).

Using if in Nginx (if is evil), causing unexpected behavior

Why it happens: Nginx if directive has quirks (not like if in programming languages). Can break location blocks, cause wrong routing, or skip directives. Called 'if is evil' in Nginx docs.

How to avoid it: Avoid if when possible. Use map, try_files, or return instead. For HTTPS redirect, use: if ($scheme != "https") { return 301 https://$host$request_uri; } (this specific if is OK).

Frequently asked questions

What is the difference between Apache and Nginx?

Apache: older, process-based, .htaccess support, easier for beginners. Nginx: newer, event-driven, faster for static files, better for high traffic, reverse proxy. Use Nginx for production.

How do I redirect HTTP to HTTPS?

Apache: RewriteCond %{HTTPS} off, RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]. Nginx: if ($scheme != "https") { return 301 https://$host$request_uri; }. Node.js: middleware checks req.protocol.

What is a reverse proxy and why use it?

Reverse proxy routes requests to backend (Node.js, Python). Nginx handles static files (fast), proxies API to backend. Benefits: SSL termination, load balancing, caching. Production standard.

How do I enable GZIP compression?

Apache: LoadModule deflate_module, AddOutputFilterByType DEFLATE text/html text/css text/javascript. Nginx: gzip on; gzip_types text/css text/javascript. Node.js: app.use(compression()).

What are security headers and why do I need them?

HSTS (force HTTPS), CSP (prevent XSS), X-Frame-Options (prevent clickjacking), X-Content-Type-Options (prevent MIME sniffing). Prevent common attacks. Required for security audits (OWASP).

How do I fix CORS errors?

Add Access-Control-Allow-Origin header. Nginx: add_header Access-Control-Allow-Origin *; (or specific domain). Express.js: app.use(cors()). Allows cross-origin requests.

What is the difference between 301 and 302 redirects?

301 = permanent (SEO transfers to new URL). 302 = temporary (SEO stays with old URL). Use 301 for domain changes, 302 for A/B testing or maintenance.

References

Privacy and availability

  • Runs entirely in your browser — zero server processing
  • No signup or account required
  • Works offline once loaded
  • Fast, lightweight, no external dependencies
  • Available as a browser extension for Chrome and Firefox