Expose AdminJS on nudentic.ir: nginx only proxied /api, so /admin never reached Nest.
This commit is contained in:
@@ -44,7 +44,7 @@ Then `sudo systemctl restart docker` (containers restart).
|
||||
- `REGISTRY_PREFIX=wixur.ir:3000/<gitea-owner>` (same owner as Gitea `REGISTRY_OWNER`)
|
||||
- `TAG=v1.0.1` (CI overrides per release)
|
||||
|
||||
3. **`secrets/backend.env`:** `FRONTEND_URL=https://nudentic.ir`, `COOKIE_SECURE=true`
|
||||
3. **`secrets/backend.env`:** `FRONTEND_URL=https://nudentic.ir`, `COOKIE_SECURE=true`, plus `ADMINJS_EMAIL` / `ADMINJS_PASSWORD` for `https://nudentic.ir/admin`
|
||||
|
||||
4. **SSH** — user that can run `docker` (e.g. `dyolink` in the `docker` group). Put the matching **public** key in `~/.ssh/authorized_keys`.
|
||||
|
||||
@@ -72,7 +72,7 @@ git push origin v1.0.1
|
||||
|
||||
Or Gitea → Actions → **Production — tag build, push, deploy** → Run → tag `v1.0.1`.
|
||||
|
||||
Check `https://nudentic.ir/api/health`.
|
||||
Check `https://nudentic.ir/api/health`. AdminJS is `https://nudentic.ir/admin`.
|
||||
|
||||
---
|
||||
|
||||
@@ -81,8 +81,9 @@ Check `https://nudentic.ir/api/health`.
|
||||
|
||||
```
|
||||
Internet → Nginx (:80 / :443)
|
||||
├── / → frontend:3000 (Next.js)
|
||||
└── /api → backend:3000 (NestJS)
|
||||
├── / → frontend:3000 (Next.js)
|
||||
├── /api → backend:3000 (NestJS API)
|
||||
└── /admin → backend:3000 (AdminJS)
|
||||
└── postgres:5432
|
||||
```
|
||||
|
||||
@@ -496,6 +497,7 @@ docker compose -f docker-compose.prod.yml --env-file .env exec frontend \
|
||||
- [ ] `.env`, `database.env`, `backend.env` configured (real passwords + JWT)
|
||||
- [ ] `./scripts/deploy-prod.sh` completed
|
||||
- [ ] `curl https://DOMAIN/api/health` returns `{"status":"ok",...}`
|
||||
- [ ] `https://DOMAIN/admin` shows the AdminJS login (not the Next.js app)
|
||||
- [ ] App loads in browser
|
||||
|
||||
---
|
||||
|
||||
@@ -14,6 +14,11 @@ JWT_REFRESH_EXPIRES_IN=30d
|
||||
# Must match DOMAIN in .env — used for CORS, invite links, cookies
|
||||
FRONTEND_URL=https://nudentic.ir
|
||||
|
||||
# AdminJS at https://nudentic.ir/admin (nginx proxies /admin to the API).
|
||||
# Change these — the code defaults are only for local development.
|
||||
ADMINJS_EMAIL=admin@nudentic.ir
|
||||
ADMINJS_PASSWORD=CHANGE_ME_STRONG_ADMINJS_PASSWORD
|
||||
|
||||
# Required for HTTPS — browsers reject Secure cookies over plain HTTP
|
||||
COOKIE_SECURE=true
|
||||
|
||||
|
||||
@@ -12,6 +12,10 @@ JWT_REFRESH_EXPIRES_IN=30d
|
||||
# CORS, cookies, and invite links — must match how users open the app
|
||||
FRONTEND_URL=https://wixur.ir
|
||||
|
||||
# AdminJS at https://wixur.ir/admin (nginx proxies /admin to the API).
|
||||
ADMINJS_EMAIL=admin@wixur.ir
|
||||
ADMINJS_PASSWORD=CHANGE_ME_STRONG_ADMINJS_PASSWORD
|
||||
|
||||
# TLS is terminated on Windows nginx :443 — cookies must be Secure
|
||||
COOKIE_SECURE=true
|
||||
|
||||
|
||||
@@ -43,6 +43,22 @@ server {
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
# AdminJS (Nest, not under /api)
|
||||
location /admin {
|
||||
set $backend_upstream http://backend:3000;
|
||||
proxy_pass $backend_upstream;
|
||||
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;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_read_timeout 300;
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
|
||||
@@ -46,6 +46,21 @@ server {
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
# AdminJS (Nest, not under /api)
|
||||
location /admin {
|
||||
proxy_pass http://dyolink_backend;
|
||||
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;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_read_timeout 300;
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
|
||||
@@ -86,6 +86,21 @@ server {
|
||||
proxy_read_timeout 300;
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
# AdminJS (Nest, not under /api)
|
||||
location /admin {
|
||||
proxy_pass http://dyolink_backend;
|
||||
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;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_read_timeout 300;
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
# Health check endpoint (no logging)
|
||||
location /health {
|
||||
|
||||
@@ -83,6 +83,21 @@ server {
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
# AdminJS (Nest, not under /api) — https://nudentic.ir/admin
|
||||
location /admin {
|
||||
proxy_pass http://dyolink_backend;
|
||||
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;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
proxy_read_timeout 300;
|
||||
proxy_connect_timeout 300;
|
||||
}
|
||||
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
|
||||
@@ -45,7 +45,16 @@ pull_one() {
|
||||
echo "Pulling backend/frontend :$TAG from Gitea (REGISTRY_PREFIX in .env)"
|
||||
pull_one backend
|
||||
pull_one frontend
|
||||
|
||||
if [ -f nginx/nginx.ssl.conf.template ]; then
|
||||
echo "Rendering nginx SSL config (includes /admin → backend)"
|
||||
chmod +x scripts/render-nginx-ssl.sh
|
||||
./scripts/render-nginx-ssl.sh
|
||||
fi
|
||||
|
||||
docker compose -f docker-compose.prod.yml --env-file .env up -d --force-recreate nginx
|
||||
docker compose -f docker-compose.prod.yml --env-file .env up -d
|
||||
echo "=== Status ==="
|
||||
docker compose -f docker-compose.prod.yml --env-file .env ps
|
||||
echo "Health: https://nudentic.ir/api/health"
|
||||
echo "AdminJS: https://nudentic.ir/admin"
|
||||
|
||||
Reference in New Issue
Block a user