# 1. HTTP: Redirect ทุก Request ไปยัง HTTPS (พร้อมเปิดช่องทางสำหรับ Certbot ต่ออายุ) server { listen 80; server_name foxxio.ddcsprocket.com; # สำหรับ Certbot ACME Challenge (ต่ออายุใบรับรองอัตโนมัติ) location /.well-known/acme-challenge/ { root /usr/share/nginx/html; try_files $uri =404; } # Redirect ทั้งหมดไปยัง HTTPS location / { return 301 https://$host$request_uri; } } # 2. HTTPS: Proxy ไปยัง Next.js SSR (Port 3003) และ Backend API (Port 3006) บน 192.168.1.26 server { listen 443 ssl; server_name foxxio.ddcsprocket.com; # ตำแหน่ง SSL Certificate ของ Let's Encrypt ssl_certificate /etc/letsencrypt/live/foxxio.ddcsprocket.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/foxxio.ddcsprocket.com/privkey.pem; # Certbot ACME Challenge location /.well-known/acme-challenge/ { root /usr/share/nginx/html; try_files $uri =404; } # Backend API: ส่งต่อไปยัง Elysia API บน 192.168.1.26:3006 location /api/ { proxy_pass http://192.168.1.26:3006; proxy_set_header Host $host; proxy_http_version 1.1; proxy_set_header Connection 'upgrade'; proxy_set_header Upgrade $http_upgrade; 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; } # Website SSR: ส่งต่อไปยัง Next.js SSR บน 192.168.1.26:3003 location / { proxy_pass http://192.168.1.26:3003; proxy_set_header Host $host; proxy_http_version 1.1; proxy_set_header Connection 'upgrade'; proxy_set_header Upgrade $http_upgrade; 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; # Buffer settings สำหรับ Next.js SSR proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k; } }