Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
86 lines
2.8 KiB
Nginx Configuration File
86 lines
2.8 KiB
Nginx Configuration File
# Шлюз Barev: Nginx Proxy Manager (TLS) → этот контейнер → статика / API / лендинг.
|
|
# Хост определяется по первому сегменту домена: app.*, pro.*, admin.*, api.*, иначе — лендинг.
|
|
|
|
map $host $barev_site {
|
|
~^app\. client;
|
|
~^pro\. pro;
|
|
~^admin\. admin;
|
|
~^api\. api;
|
|
default landing;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
client_max_body_size 12m;
|
|
server_tokens off;
|
|
|
|
# www.barevclub.com → barevclub.com: один адрес для SEO и CORS (API разрешает только основной домен)
|
|
if ($host ~* ^www\.(.+)$) {
|
|
return 301 https://$1$request_uri;
|
|
}
|
|
|
|
# NPM терминирует TLS и передаёт схему в X-Forwarded-Proto: http → https для всех хостов Barev.
|
|
# ACME-проверки Let's Encrypt NPM обрабатывает сам, сюда они не доходят.
|
|
if ($http_x_forwarded_proto = "http") {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000" always;
|
|
add_header X-Content-Type-Options nosniff always;
|
|
add_header Referrer-Policy strict-origin-when-cross-origin always;
|
|
|
|
gzip on;
|
|
gzip_types text/css application/javascript application/json image/svg+xml;
|
|
|
|
# API доступен с любого хоста Barev — Mini App и админка ходят в него с того же origin
|
|
location /trpc/ {
|
|
proxy_pass http://barev-app:4000;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
}
|
|
location /files/ {
|
|
proxy_pass http://barev-app:4000;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
location = /client-log {
|
|
proxy_pass http://barev-app:4000;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
location = /health {
|
|
proxy_pass http://barev-app:4000;
|
|
}
|
|
|
|
location / {
|
|
if ($barev_site = landing) {
|
|
proxy_pass http://barev-landing:3000;
|
|
}
|
|
if ($barev_site = api) {
|
|
return 404;
|
|
}
|
|
root /srv/$barev_site;
|
|
index index.html;
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# index.html Mini App и админки не кешируем: иначе Telegram держит старую страницу со ссылкой на старый бандл
|
|
location = /index.html {
|
|
if ($barev_site = landing) {
|
|
proxy_pass http://barev-landing:3000;
|
|
}
|
|
root /srv/$barev_site;
|
|
add_header Cache-Control "no-cache";
|
|
}
|
|
|
|
# статика с хешами в имени — кешируем надолго
|
|
location /assets/ {
|
|
root /srv/$barev_site;
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
try_files $uri =404;
|
|
}
|
|
}
|