# ========================================================= # HABERKEYFI.COM.TR - NİHAİ CONFIG (TÜMÜ AKTİF + Statik Dosya Düzeltmesi) # ========================================================= # --------------------------------------------------------- # BLOK 1: IP ADRESİ / KÖK DİZİN (HTTP - SSL YOK) # (Öncekiyle aynı) # --------------------------------------------------------- server { listen 80 default_server; server_name 91.198.66.10 127.0.0.1 localhost; root "C:/laragon/www/"; index index.php index.html index.htm; autoindex on; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } } # --------------------------------------------------------- # BLOK 2: DOMAINLER İÇİN HTTP → HTTPS YÖNLENDİRME # (Öncekiyle aynı) # --------------------------------------------------------- server { listen 80; server_name haberkeyfi.com.tr www.haberkeyfi.com.tr api.haberkeyfi.com.tr; location ^~ /.well-known/acme-challenge/ { allow all; root "C:/laragon/www"; } location / { return 301 https://$host$request_uri; } } # --------------------------------------------------------- # BLOK 3: HTTPS Ana Site (Next.js + Socket.IO) - GÜNCELLENDİ # --------------------------------------------------------- server { listen 443 ssl http2 default_server; server_name haberkeyfi.com.tr www.haberkeyfi.com.tr; charset utf-8; ssl_certificate "C:/laragon/etc/ssl/haberkeyfi.com.tr-fullchain.pem"; ssl_certificate_key "C:/laragon/etc/ssl/haberkeyfi.com.tr-key.pem"; location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } location ~ /\.ht { deny all; } # Socket.IO (Port 3001) location /socket.io/ { proxy_pass http://127.0.0.1:3001/socket.io/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; 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; } # ========================================================= # YENİ: STATİK DOSYALARI (RESİMLER, CSS, JS) DOĞRUDAN SUN # ========================================================= # Next.js projenizin 'public' klasörünü hedefliyoruz. # Proje yolunuz: C:/laragon/www/haberkeyfi # Public klasörü: C:/laragon/www/haberkeyfi/public # # Bu blok, / (Next.js) bloğundan ÖNCE gelmelidir. location ~* \.(jpg|jpeg|png|gif|ico|webp|mp4)$ { root "C:/laragon/www/haberkeyfi/public"; expires 30d; # Tarayıcıda 30 gün önbelleğe al access_log off; # Logları kirletme } # ========================================================= # NEXT.JS (Port 3000) # Bu blok artık sadece statik dosya olmayan (sayfa) isteklerini yakalayacak location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; 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; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; autoindex off; } } # --------------------------------------------------------- # BLOK 4: HTTPS API Alt Domain (Python/FastAPI Backend) # TEMİZ REVERSE PROXY (CORS'u Python'a bırak) # --------------------------------------------------------- server { listen 443 ssl http2; server_name api.haberkeyfi.com.tr; charset utf-8; # API Sertifikaları (Aynı kalıyor) ssl_certificate "C:/laragon/etc/ssl/api.haberkeyfi.com.tr-crt.pem"; ssl_certificate_key "C:/laragon/etc/ssl/api.haberkeyfi.com.tr-key.pem"; # Yazım hatası düzeltildi # --------------------------------------------------- # PYTHON YÖNLENDİRME (REVERSE PROXY) # --------------------------------------------------- # Tüm CORS ayarları buradan kaldırıldı. location / { # İsteği Python (Uvicorn) sunucunun çalıştığı porta yönlendir proxy_pass http://127.0.0.1:1000; # Python/FastAPI'nin istemci IP'sini, Host'u vb. doğru görmesi için # Bu başlıklar kritik öneme sahiptir. 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; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Port $server_port; } # .ht dosyalarını engelle (iyi bir güvenlik önlemidir, kalabilir) location ~ /\.ht { deny all; } # favicon.ico ve robots.txt istekleri Python uygulamasına gidecek # ve uygulama içindeki @app.get("/") ana sayfa yoluna düşecek veya 404 alacak. location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } } # ----------------------------------------------------------------- # BLOK 5: FastAPI (Python) Özetleme API'si (GÜNCELLENDİ) # ozetle.haberkeyfi.com.tr -> http://localhost:8123 # ----------------------------------------------------------------- server { listen 443 ssl http2; server_name ozetle.haberkeyfi.com.tr; # --- SSL SERTİFİKALARI --- # win-acme ile C:\laragon\etc\ssl klasörüne oluşturuldu ssl_certificate "C:/laragon/etc/ssl/ozetle.haberkeyfi.com.tr-crt.pem"; ssl_certificate_key "C:/laragon/etc/ssl/ozetle.haberkeyfi.com.tr-key.pem"; # --- CORS AYARLARI --- add_header 'Access-Control-Allow-Origin' 'https://haberkeyfi.com.tr' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; # --- PROXY AYARLARI --- location / { # CORS (OPTIONS) isteklerini yakala if ($request_method = 'OPTIONS') { add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; } # İsteği FastAPI Sunucusuna Yönlendir proxy_pass http://127.0.0.1:8123; # Proxy Başlıkları 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; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } # --- DÜZELTME --- # Nginx'in çökmesine (başlamamasına) neden olan sorun muhtemelen # "C:/laragon/logs/nginx/" klasörünün mevcut olmamasıdır. # Nginx klasörleri otomatik oluşturmaz. # Sorunu gidermek için bu satırları geçici olarak devre dışı bıraktık. # access_log "C:/laragon/logs/nginx/ozetle.haberkeyfi.com.tr-access.log"; # error_log "C:/laragon/logs/nginx/ozetle.haberkeyfi.com.tr-error.log"; # .ht dosyalarını engelle location ~ /\.ht { deny all; } } # ----------------------------------------------------------------- # BLOK 6: FastAPI (Python) Konum API'si (HTTPS AKTİF) # https://konum.haberkeyfi.com.tr -> http://localhost:9150 # ----------------------------------------------------------------- server { listen 443 ssl http2; server_name konum.haberkeyfi.com.tr; # --- SSL SERTİFİKALARI (YENİ OLUŞTURULAN) --- ssl_certificate "C:/laragon/etc/ssl/konum.haberkeyfi.com.tr-crt.pem"; ssl_certificate_key "C:/laragon/etc/ssl/konum.haberkeyfi.com.tr-key.pem"; # --- CORS AYARLARI --- add_header 'Access-Control-Allow-Origin' 'https://haberkeyfi.com.tr' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; # --- PROXY AYARLARI --- location / { # CORS (OPTIONS) isteklerini yakala if ($request_method = 'OPTIONS') { add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; } # İsteği FastAPI Konum Sunucusuna Yönlendir proxy_pass http://127.0.0.1:9150; # Proxy Başlıkları 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; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } # .ht dosyalarını engelle location ~ /\.ht { deny all; } } # ----------------------------------------------------------------- # BLOK 7: HTTP -> HTTPS Yönlendirme (konum) # http://konum.haberkeyfi.com.tr -> https://... # ----------------------------------------------------------------- server { listen 80; server_name konum.haberkeyfi.com.tr; # win-acme doğrulamasının gelecekte çalışması için # .well-known isteklerine izin ver location ^~ /.well-known/acme-challenge/ { root C:/laragon/www/; try_files $uri $uri/ =404; } # Geri kalan tüm istekleri 301 (kalıcı) olarak HTTPS'e yönlendir location / { return 301 https://$host$request_uri; } }