49 lines
1.4 KiB
Nginx Configuration File
49 lines
1.4 KiB
Nginx Configuration File
# Единая точка входа: снаружи открыт только proxy.
|
||
# Внутренние сервисы web и api не публикуют порты на хост — только expose в compose.
|
||
|
||
worker_processes auto;
|
||
error_log /var/log/nginx/error.log warn;
|
||
pid /tmp/nginx.pid;
|
||
|
||
events {
|
||
worker_connections 1024;
|
||
}
|
||
|
||
http {
|
||
include /etc/nginx/mime.types;
|
||
default_type application/octet-stream;
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||
'$status $body_bytes_sent "$http_referer" '
|
||
'"$http_user_agent"';
|
||
access_log /var/log/nginx/access.log main;
|
||
sendfile on;
|
||
keepalive_timeout 65;
|
||
|
||
# DNS резолвится внутри Docker-сети по именам сервисов
|
||
upstream web_upstream {
|
||
server web:80;
|
||
}
|
||
|
||
upstream api_upstream {
|
||
server api:5000;
|
||
}
|
||
|
||
server {
|
||
listen 80;
|
||
server_name _;
|
||
|
||
location / {
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_pass http://web_upstream;
|
||
}
|
||
|
||
# Запросы /api/* уходят на api без префикса /api (trailing slash у proxy_pass)
|
||
location /api/ {
|
||
proxy_set_header Host $host;
|
||
proxy_set_header X-Real-IP $remote_addr;
|
||
proxy_pass http://api_upstream/;
|
||
}
|
||
}
|
||
}
|