# Nginx สำหรับ srv1361159.hstgr.cloud — ใช้แทนของเดิมใน /etc/nginx/sites-available/ # คัดลอกไปที่เซิร์ฟเวอร์: sudo cp srv1361159.hstgr.cloud.conf /etc/nginx/sites-available/srv1361159.hstgr.cloud # แล้ว: sudo nginx -t && sudo systemctl reload nginx server { server_name srv1361159.hstgr.cloud; root /var/www/html; index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php8.3-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } # RealtimeChat — ไฟล์จากโฟลเดอร์ + Socket.IO ไป Node location /realtimechat/ { alias /var/www/html/realtimechat/public/; index index.html; try_files $uri $uri/ /realtimechat/index.html; } location /realtimechat/socket.io/ { proxy_pass http://127.0.0.1:3000; 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; } # Game (ZEP-like) — รูปตัวละครอยู่ที่ Node (data/characters) location /Game/img/characters/ { proxy_pass http://127.0.0.1:3001; 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; } # Game — API ต้องรับ body ใหญ่ (รูปพื้นหลัง base64) จึงตั้ง 20M location /Game/api/ { client_max_body_size 20M; proxy_pass http://127.0.0.1:3001; 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; } location /Game/ { alias /var/www/html/Game/public/; index index.html; try_files $uri $uri/ /Game/index.html; } location /Game/socket.io/ { proxy_pass http://127.0.0.1:3001; 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; } listen [::]:443 ssl ipv6only=on; listen 443 ssl; ssl_certificate /etc/letsencrypt/live/srv1361159.hstgr.cloud/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/srv1361159.hstgr.cloud/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; } server { if ($host = srv1361159.hstgr.cloud) { return 301 https://$host$request_uri; } listen 80 default_server; listen [::]:80 default_server; server_name srv1361159.hstgr.cloud; return 404; }