server { listen 80; server_name localhost; # Oder deine Domain # Root-Verzeichnis für statische Dateien root /usr/share/nginx/html; index index.html; # Logging (optional, aber nützlich) access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; # Clean URL rewrites - Map short URLs to actual HTML files rewrite ^/dns$ /dns-lookup.html last; rewrite ^/dns-lookup$ /dns-lookup.html last; rewrite ^/whois$ /whois-lookup.html last; rewrite ^/whois-lookup$ /whois-lookup.html last; rewrite ^/mac$ /mac-lookup.html last; rewrite ^/mac-lookup$ /mac-lookup.html last; rewrite ^/subnet$ /subnet-calculator.html last; rewrite ^/subnet-calculator$ /subnet-calculator.html last; rewrite ^/asn$ /asn-lookup.html last; rewrite ^/asn-lookup$ /asn-lookup.html last; # Statische Dateien direkt ausliefern location / { # First try the exact URI, then with .html, then fall back to index.html try_files $uri $uri.html $uri/ /index.html; } # API-Anfragen an den Backend-Service weiterleiten location /api/ { # Der Name 'backend' muss dem Service-Namen in docker-compose.yml entsprechen proxy_pass http://backend:3000; # Leitet an den Backend-Container auf Port 3000 weiter # Wichtige Proxy-Header setzen 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; # Header für Server-Sent Events (Traceroute) proxy_set_header Connection ''; proxy_http_version 1.1; proxy_buffering off; # Wichtig für Streaming proxy_cache off; # Wichtig für Streaming proxy_read_timeout 300s; # Längerer Timeout für potenziell lange Traceroutes } } # Upstream-Definition (optional, aber sauberer für proxy_pass) # upstream backend_server { # server backend:3000; # } # Dann in location /api/: proxy_pass http://backend_server;