push
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM nginx:1.27-alpine
|
||||
|
||||
LABEL service="proxy" description="Reverse proxy to web + api"
|
||||
|
||||
# Заменяем дефолтный конфиг на свой (в образе — воспроизводимо)
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget -qO- http://127.0.0.1/ >/dev/null || exit 1
|
||||
@@ -0,0 +1,48 @@
|
||||
# Единая точка входа: снаружи открыт только 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/;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user