167 lines
5.0 KiB
Plaintext
167 lines
5.0 KiB
Plaintext
# ==============================================================================
|
|
# Acupedia Platform — Central Containerized Nginx Gateway Configuration
|
|
# File: config/nginx/acupedia.conf
|
|
#
|
|
# Container Upstreams:
|
|
# - Backend API -> backend:8000
|
|
# - Storefront -> store:80
|
|
# - Admin Suite -> admin:80
|
|
# - MinIO S3 -> minio:9000
|
|
# ==============================================================================
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# Upstream Definitions (Docker Internal DNS on acupedia-net)
|
|
# ------------------------------------------------------------------------------
|
|
upstream backend_api {
|
|
server backend:8000;
|
|
keepalive 32;
|
|
}
|
|
|
|
upstream store_app {
|
|
server store:80;
|
|
keepalive 16;
|
|
}
|
|
|
|
upstream admin_app {
|
|
server admin:80;
|
|
keepalive 16;
|
|
}
|
|
|
|
upstream minio_storage {
|
|
server minio:9000;
|
|
keepalive 32;
|
|
}
|
|
|
|
# ==============================================================================
|
|
# 1. HTTP to HTTPS Global Redirect (Ports 80 -> 443)
|
|
# ==============================================================================
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name acupedia.in www.acupedia.in api.acupedia.in;
|
|
|
|
# Let's Encrypt ACME challenge (used for certbot renewal)
|
|
location /.well-known/acme-challenge/ {
|
|
root /var/www/certbot;
|
|
}
|
|
|
|
# Redirect all HTTP requests to HTTPS
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
|
|
# ==============================================================================
|
|
# 2. Dedicated API Subdomain (api.acupedia.in)
|
|
# ==============================================================================
|
|
server {
|
|
listen 443 ssl;
|
|
listen [::]:443 ssl;
|
|
server_name api.acupedia.in;
|
|
|
|
# SSL Certificates (Mounted from host /etc/letsencrypt)
|
|
ssl_certificate /etc/letsencrypt/live/acupedia.in/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/acupedia.in/privkey.pem;
|
|
include /etc/letsencrypt/options-ssl-nginx.conf;
|
|
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
|
|
|
client_max_body_size 50M;
|
|
|
|
# Common Proxy Headers
|
|
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;
|
|
|
|
proxy_connect_timeout 60s;
|
|
proxy_send_timeout 120s;
|
|
proxy_read_timeout 120s;
|
|
|
|
# If opened in a browser from the mobile app, redirect to main storefront
|
|
location /cart {
|
|
return 301 https://acupedia.in$request_uri;
|
|
}
|
|
|
|
location /checkout {
|
|
return 301 https://acupedia.in$request_uri;
|
|
}
|
|
|
|
# MinIO S3 Presigned Media Proxy (/accupedia-media/ and /acupedia-media/)
|
|
location /accupedia-media/ {
|
|
proxy_pass http://minio_storage;
|
|
proxy_set_header Host $http_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 /acupedia-media/ {
|
|
proxy_pass http://minio_storage;
|
|
proxy_set_header Host $http_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;
|
|
}
|
|
|
|
# FastAPI Swagger Docs & OpenAPI Schema
|
|
location /docs {
|
|
proxy_pass http://backend_api/docs;
|
|
}
|
|
|
|
location /openapi.json {
|
|
proxy_pass http://backend_api/openapi.json;
|
|
}
|
|
|
|
# Route all API traffic to FastAPI Backend on port 8000
|
|
location / {
|
|
proxy_pass http://backend_api;
|
|
}
|
|
}
|
|
|
|
# ==============================================================================
|
|
# 3. Main Domain: Storefront (/) and Admin Panel (/admin)
|
|
# ==============================================================================
|
|
server {
|
|
listen 443 ssl;
|
|
listen [::]:443 ssl;
|
|
server_name acupedia.in www.acupedia.in;
|
|
|
|
# SSL Certificates (Mounted from host /etc/letsencrypt)
|
|
ssl_certificate /etc/letsencrypt/live/acupedia.in/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/acupedia.in/privkey.pem;
|
|
include /etc/letsencrypt/options-ssl-nginx.conf;
|
|
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
|
|
|
client_max_body_size 50M;
|
|
|
|
# Common Proxy Headers
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_set_header Host $host;
|
|
proxy_cache_bypass $http_upgrade;
|
|
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_connect_timeout 60s;
|
|
proxy_send_timeout 120s;
|
|
proxy_read_timeout 120s;
|
|
|
|
# Admin Panel (/admin)
|
|
location /admin {
|
|
proxy_pass http://admin_app;
|
|
}
|
|
|
|
# Backend API access via same-origin (acupedia.in/api/ -> avoids CORS)
|
|
location /api/ {
|
|
proxy_pass http://backend_api/api/;
|
|
}
|
|
|
|
# Storefront Customer Web App (/)
|
|
location / {
|
|
proxy_pass http://store_app;
|
|
}
|
|
}
|