type
concept
created
Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
updated
Tue Apr 07 2026 02:00:00 GMT+0200 (Central European Summer Time)
sources
raw/notes/techContext
tags
nginx routing reverse-proxy ssl infrastructure deployment

Nginx MVP Routing

abstract
Nginx on b2bpaper.xdvu.com reverse-proxies `/mvp/` to gunicorn on port 8910, serves static files directly, and handles SSL termination via Let's Encrypt.

Overview

Nginx acts as the reverse proxy and static file server for the wiki/entities/b2bpaper platform. The configuration lives at /etc/nginx/sites-available/b2bpaper.xdvu.com (symlinked to sites-enabled/). All public traffic flows through Nginx before reaching the Django backend.

Route Map

b2bpaper.xdvu.com
 │
 ├── /mvp/                    → proxy_pass http://127.0.0.1:8910
 │    ├── /mvp/api/           → Django REST Framework endpoints
 │    │    ├── /mvp/api/v1/   → API version 1 endpoints
 │    │    └── /mvp/api/docs/ → Swagger UI (drf-spectacular)
 │    ├── /mvp/admin/         → Django Admin interface
 │    └── /mvp/app/           → Angular SPA (static files)
 │
 ├── /mvp/static/             → alias to backend/staticfiles/
 │    (served directly by Nginx, not proxied to Django)
 │
 └── / (root)                 → redirect or default handler

Key Routing Details

API and Admin Routes (/mvp/)

All requests to /mvp/ are proxied to gunicorn running on 127.0.0.1:8910. Django's FORCE_SCRIPT_NAME = '/mvp' ensures that Django generates correct URLs despite being mounted at a subpath.

Nginx passes the following headers to gunicorn:

Static Files (/mvp/static/)

Static files are served directly by Nginx from backend/staticfiles/ (collected via python manage.py collectstatic). This bypasses gunicorn entirely for better performance.

Angular Frontend (/mvp/app/)

The built Angular SPA is served from /var/www/hub/b2bpaper-app/. Nginx serves these as static files. The Angular app's <base href> is set to match the mount path.

SSL Termination

Nginx handles all SSL using a Let's Encrypt wildcard certificate. HTTP requests are redirected to HTTPS. The certificate covers b2bpaper.xdvu.com and is shared with tracker.xdvu.com.

Configuration Location

Relationship to Django Config

The Nginx routing and Django configuration must stay in sync:

Setting Nginx Django
Mount path location /mvp/ FORCE_SCRIPT_NAME = '/mvp'
Static URL location /mvp/static/ alias STATIC_URL = '/mvp/static/'
Backend port proxy_pass :8910 Gunicorn binds :8910

If either side changes, the other must be updated to match.

Sources

Related