zkt26/zadanie 1/nginx.conf
2026-03-22 12:58:49 +01:00

43 lines
1.8 KiB
Nginx Configuration File
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# =============================================================
# nginx.conf Konfigurácia webservera Nginx
# =============================================================
# Nginx plní dve úlohy naraz:
# 1. Servuje statické HTML/CSS/JS súbory frontendu
# 2. Funguje ako reverse proxy preposiela /api/* requesty na backend
#
# Reverse proxy = Nginx stojí pred backendom a preposiela mu requesty
# Klient (prehliadač) vidí iba Nginx na porte 80, backend je skrytý
# =============================================================
server {
# Počúvame na porte 80 (štandardný HTTP port)
listen 80;
# Koreňový adresár so statickými súbormi frontendu
root /usr/share/nginx/html;
# Predvolený súbor keď sa otvorí / (koreň webu)
index index.html;
# ── Statické súbory (frontend) ────────────────────────────
# Každá URL, ktorá nezačína /api, sa obsluží ako statický súbor
location / {
# try_files: skús súbor → adresár → vráť index.html
# Posledné "/" zabezpečí, že vždy vrátime index.html
try_files $uri $uri/ /index.html;
}
# ── Reverse proxy pre API ──────────────────────────────────
# Všetky requesty začínajúce /api sa presmerujú na backend
location /api/ {
# "backend" je názov služby v Docker Compose
# Docker vyrieši toto meno na IP adresu backend kontajnera
proxy_pass http://backend:3000;
# Hlavičky informujeme backend o pôvodnom requeste
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}