Tarayıcıda İşlenirYeni

Nginx & Apache Konfigürasyon Üretici

Web sunucularınız için HTTPS yönlendirme, SPA fallback, güvenlik başlıkları (HSTS, CSP), gzip sıkıştırma ve önbellekleme kurallarını görsel olarak oluşturun.

Sunucu ve Yönlendirme Tercihleri

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;
    }

}

Nginx ve Apache Konfigürasyonu Nasıl Oluşturulur?

1
Adım 1

Nginx veya Apache (.htaccess) sunucu tipini seçin.

2
Adım 2

Alan adınızı (örnek: siteniz.com) ve web kök dizini yolunu yazın.

3
Adım 3

HTTPS yönlendirmesi, SPA routing ve güvenlik başlıkları kutucuklarını ihtiyacınıza göre açıp kapatın.

4
Adım 4

Hazırlanan yapılandırma dosyasını kopyalayarak sunucunuza uygulayın.

Web Sunucu Konfigürasyonu SSS

SPA routing ayarı neden gereklidir?

React, Vue veya Next.js gibi istemci taraflı yönlendiriciye sahip uygulamalarda sayfayı yenilediğinizde sunucunun 404 vermesini önleyip isteği index.html'e devreder.

HSTS başlığı ne işe yarar?

Tarayıcılara web sitenizin yalnızca şifreli HTTPS protokolü üzerinden ziyaret edilmesi gerektiğini bildirerek Man-in-the-Middle (MITM) saldırılarını engeller.