44 lines
1.6 KiB
Plaintext
44 lines
1.6 KiB
Plaintext
# Konfiguracja nginx jako template — oficjalny entrypoint obrazu nginx robi envsubst
|
|
# WYLACZNIE po zdefiniowanych zmiennych srodowiska (API_UPSTREAM), a wynik zapisuje
|
|
# do /etc/nginx/conf.d/default.conf. Zmienne nginx ($uri, $host, ...) sa bezpieczne.
|
|
# API_UPSTREAM przykladowo: fitos-api:9002 (dev, wspolna siec fitos-net) lub api:9002
|
|
# (stos deploy — ta sama siec compose).
|
|
server {
|
|
listen 9000;
|
|
server_name _;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
location ~ ^/(index\.html|config\.js|manifest\.json)$ {
|
|
add_header Cache-Control "no-cache";
|
|
try_files $uri /index.html;
|
|
}
|
|
|
|
# same-origin: API przez ten sam origin co SPA — ciastko refresh (SameSite=Lax)
|
|
# zawsze leci, brak CORS. Naglowki X-Forwarded-* sa wymagane przez trust proxy
|
|
# w Expressie (limity per-IP liczona po adresie klienta, nie nginxa).
|
|
location /api/ {
|
|
# upload zdjec do 5 MB + zapas
|
|
client_max_body_size 10m;
|
|
proxy_pass http://${API_UPSTREAM};
|
|
# $http_host (nie $host!) — zachowuje port: Express porownuje Origin z Host
|
|
# i inaczej requesty na srodowisku z jawnych portem (staging 13xxx, dev 9xxx)
|
|
# wygladalyby na cross-origin
|
|
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 = /health {
|
|
proxy_pass http://${API_UPSTREAM};
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
}
|
|
|
|
location / {
|
|
try_files $uri /index.html;
|
|
}
|
|
}
|