mirror of
https://github.com/dong-nz/cv.git
synced 2026-11-22 16:10:40 +07:00
chore(deploy): auth-protected /api/content/ proxy with Gitea token passthrough
nginx template location with basic auth (deploy/htpasswd) + envsubst'd GITEA_TOKEN; compose mounts template + htpasswd; vite dev proxy mirrors nginx exactly for edit-mode development.
This commit is contained in:
1 parent
e6b4d83084
commit
f113dfc7b5
4 files changed
+47
-1
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
editor:$6$ZLNQoSEIIH8uSXd6$mSxe2JJETZV30nt/Gm..mS4h3VAIBuWdfdqmaFmPknyXpwiKEQ0WR8HZihgTDkDp7hmj5oRqLS2Vnn.e9bBsx0
|
||||||
+11
-1
@@ -3,9 +3,19 @@ services:
|
|||||||
image: nginx:alpine
|
image: nginx:alpine
|
||||||
container_name: dong-site
|
container_name: dong-site
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
# The write token for the /api/content/ proxy (spec-v4 §6.2). Set it in
|
||||||
|
# the local .env; NGINX_ENVSUBST_FILTER restricts the template
|
||||||
|
# substitution to this variable only, so $uri/$host stay nginx runtime
|
||||||
|
# variables.
|
||||||
|
GITEA_TOKEN: ${GITEA_TOKEN}
|
||||||
|
NGINX_ENVSUBST_FILTER: GITEA_TOKEN
|
||||||
volumes:
|
volumes:
|
||||||
- ./dist:/usr/share/nginx/html:ro
|
- ./dist:/usr/share/nginx/html:ro
|
||||||
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
|
# Mounted as a template: the image's envsubst step renders it to
|
||||||
|
# /etc/nginx/conf.d/default.conf with GITEA_TOKEN filled in.
|
||||||
|
- ./nginx.conf:/etc/nginx/templates/default.conf.template:ro
|
||||||
|
- ./deploy/htpasswd:/etc/nginx/htpasswd:ro
|
||||||
networks:
|
networks:
|
||||||
- docker-network
|
- docker-network
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
+14
@@ -38,4 +38,18 @@ server {
|
|||||||
access_log off;
|
access_log off;
|
||||||
log_not_found off;
|
log_not_found off;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Content write path (spec-v4 §6.2): Basic-auth at the proxy, the Gitea
|
||||||
|
# write token lives only in the container environment (${GITEA_TOKEN} is
|
||||||
|
# substituted by the image's envsubst template step — the SPA bundle never
|
||||||
|
# carries a write-capable token).
|
||||||
|
location /api/content/ {
|
||||||
|
auth_basic "Editor";
|
||||||
|
auth_basic_user_file /etc/nginx/htpasswd;
|
||||||
|
|
||||||
|
proxy_pass https://code.vugado.com/api/v1/repos/dong.nguyen/cv/contents/;
|
||||||
|
proxy_ssl_server_name on;
|
||||||
|
proxy_set_header Host code.vugado.com;
|
||||||
|
proxy_set_header Authorization "token ${GITEA_TOKEN}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,4 +9,25 @@ export default defineConfig({
|
|||||||
'@': path.resolve(import.meta.dirname, './src'),
|
'@': path.resolve(import.meta.dirname, './src'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
server: {
|
||||||
|
// Mirror the production nginx `/api/content/` proxy (spec-v4 §6.2) so edit
|
||||||
|
// mode works against the real repository during development. Start with
|
||||||
|
// `GITEA_TOKEN=... pnpm dev`; without the token the proxy answers 404 and
|
||||||
|
// edit mode falls back to the offline state.
|
||||||
|
proxy: {
|
||||||
|
'/api/content/': {
|
||||||
|
target: 'http://192.168.10.8:3080',
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (p) => {
|
||||||
|
return p.replace(/^\/api\/content\//, '/api/v1/repos/dong.nguyen/cv/contents/');
|
||||||
|
},
|
||||||
|
configure: (proxy) => {
|
||||||
|
proxy.on('proxyReq', (proxyReq) => {
|
||||||
|
const token = process.env.GITEA_TOKEN
|
||||||
|
if (token) proxyReq.setHeader('Authorization', `token ${token}`)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
Reference in new issue
Block a user