Initial: Project justice — nginx srv1361159.hstgr.cloud

Made-with: Cursor
This commit is contained in:
2026-04-24 08:25:30 +00:00
commit b525085e2b
5 changed files with 149 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
.DS_Store
+23
View File
@@ -0,0 +1,23 @@
# Project justice
Git สำหรับเก็บ **เฉพาะ** ไฟล์ Nginx ของ `https://srv1361159.hstgr.cloud` (ไม่รวม vhost อื่น เช่น git.*)
## Layout
- `nginx/srv1361159.hstgr.cloud` — mirror ของ `/etc/nginx/sites-available/srv1361159.hstgr.cloud`
## หลังแก้ใน repo แล้ว (นำขึ้น production)
```bash
sudo /root/repos/justice/scripts/deploy-nginx.sh
```
## แก้ที่ `/etc/nginx/...` โดยตรง → ดึงเข้า repo + commit + push
```bash
/root/repos/justice/scripts/save-from-etc.sh "อธิบายการเปลี่ยนแปลง"
```
## Remote
- https://git.srv1361159.hstgr.cloud/giteaadmin/justice.git
+102
View File
@@ -0,0 +1,102 @@
# 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;
}
location ^~ /Admin/private/ {
deny all;
return 404;
}
# 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/(?!socket\.io/)(.+\.(html|js))$ {
alias /var/www/html/Game/public/$1;
add_header Cache-Control "no-store, no-cache, must-revalidate";
}
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;
}
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
SRC="$(cd "$(dirname "$0")/.." && pwd)/nginx/srv1361159.hstgr.cloud"
DST="/etc/nginx/sites-available/srv1361159.hstgr.cloud"
install -o root -g root -m 644 "$SRC" "$DST"
nginx -t
systemctl reload nginx
echo "OK: deployed $SRC -> $DST and nginx reloaded."
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
set -euo pipefail
REPO="$(cd "$(dirname "$0")/.." && pwd)"
MSG="${1:-Update nginx srv1361159.hstgr.cloud}"
cp -a /etc/nginx/sites-available/srv1361159.hstgr.cloud "$REPO/nginx/srv1361159.hstgr.cloud"
cd "$REPO"
git add nginx/srv1361159.hstgr.cloud README.md scripts 2>/dev/null || git add nginx/srv1361159.hstgr.cloud
if git diff --cached --quiet 2>/dev/null; then
echo "No changes to commit."
exit 0
fi
git commit -m "$MSG" || true
TOKEN="$(cat /root/.config/gitea-justice.token)"
git push "https://giteaadmin:${TOKEN}@git.srv1361159.hstgr.cloud/giteaadmin/justice.git" main
echo "OK: committed and pushed."