Client-SideNew

Nginx & Apache Config Generator

Visually configure Nginx (nginx.conf) and Apache (.htaccess) rules for HTTPS redirection, SPA pushState routing, security headers (HSTS, CSP), and static caching.

Server & Routing Options

nginx.conf / sites-available

# =================================================
# Nginx Server Configuration for: example.com
# Generated by Yazılım Motoru (https://yazilimmotoru.com)
# =================================================

server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.example.com;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    return 301 https://example.com$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    server_name example.com;
    root /var/www/example.com/html;
    index index.html index.htm index.php;

    # Security Headers
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;
    add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

    # Gzip Compression
    gzip on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml;

    # Single Page Application (SPA) HTML5 PushState Routing
    location / {
        try_files $uri $uri/ /index.html;
    }

    # Browser Caching for Static Assets
    location ~* \.(?:css|js|jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff|woff2|ttf|eot)$ {
        expires 1y;
        access_log off;
        add_header Cache-Control "public, max-age=31536000, immutable";
    }

    # Deny access to hidden dotfiles (.git, .env, etc.)
    location ~ /\.(?!well-known) {
        deny all;
        access_log off;
        log_not_found off;
    }

}

How to Generate Nginx & Apache Config?

1
Step 1

Select your web server environment: Nginx or Apache (.htaccess).

2
Step 2

Enter your domain name (e.g. example.com) and document root folder.

3
Step 3

Toggle HTTPS redirection, Single Page App routing, and security headers as needed.

4
Step 4

Copy or download the generated configuration and paste it onto your server.

Web Server Config FAQ

Why is SPA routing necessary?

Client-side routing frameworks like React, Vue, or Next.js static exports require the web server to rewrite all unknown paths back to index.html to avoid 404 errors on browser refresh.

What is HSTS?

HTTP Strict Transport Security (HSTS) instructs modern web browsers that a website must strictly be accessed over HTTPS, preventing SSL stripping and MITM attacks.