Skip to content

Commit

Permalink
add dev nginx config
Browse files Browse the repository at this point in the history
  • Loading branch information
MatiXxD committed Dec 11, 2024
1 parent d2b6aae commit ebf2020
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 17 deletions.
62 changes: 46 additions & 16 deletions docker/docker-compose.prod.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
networks:
prometheus:
prometheus-exporters:
app-network:
driver: bridge

services:
novamusic-user:
Expand All @@ -22,6 +24,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network
volumes:
- /etc/ssl/nova-music.ru:/etc/ssl/nova-music.ru

Expand All @@ -44,6 +47,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network
volumes:
- /etc/ssl/nova-music.ru:/etc/ssl/nova-music.ru

Expand All @@ -66,6 +70,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network
volumes:
- /etc/ssl/nova-music.ru:/etc/ssl/nova-music.ru

Expand All @@ -88,6 +93,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network
volumes:
- /etc/ssl/nova-music.ru:/etc/ssl/nova-music.ru

Expand All @@ -110,6 +116,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network
volumes:
- /etc/ssl/nova-music.ru:/etc/ssl/nova-music.ru

Expand All @@ -132,6 +139,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network
volumes:
- /etc/ssl/nova-music.ru:/etc/ssl/nova-music.ru

Expand All @@ -154,6 +162,7 @@ services:
networks:
- prometheus
- prometheus-exporters
- app-network
volumes:
- /etc/ssl/nova-music.ru:/etc/ssl/nova-music.ru

Expand All @@ -176,7 +185,7 @@ services:
healthcheck:
test:
[
'CMD-SHELL',
"CMD-SHELL",
"sh -c 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'",
]
interval: 2s
Expand Down Expand Up @@ -254,11 +263,11 @@ services:
image: prom/node-exporter:latest
container_name: node-exporter
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
- '--no-collector.rapl'
- "--path.procfs=/host/proc"
- "--path.rootfs=/rootfs"
- "--path.sysfs=/host/sys"
- "--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)"
- "--no-collector.rapl"
restart: unless-stopped
expose:
- 9100
Expand All @@ -274,13 +283,13 @@ services:
container_name: prometheus
env_file: .prod.env
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus/'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=365d'
- '--web.external-url=${PROMETHEUS_URL}'
- '--web.enable-admin-api'
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus/"
- "--web.console.libraries=/etc/prometheus/console_libraries"
- "--web.console.templates=/etc/prometheus/consoles"
- "--storage.tsdb.retention.time=365d"
- "--web.external-url=${PROMETHEUS_URL}"
- "--web.enable-admin-api"
restart: unless-stopped
expose:
- 8002
Expand Down Expand Up @@ -330,9 +339,9 @@ services:
- ./alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml
- ./alertmanager/telegram.tmpl:/etc/alertmanager/telegram.tmpl
command:
- '--config.file=/etc/alertmanager/alertmanager.yml'
- '--storage.path=/alertmanager'
- '--web.external-url=${ALERTMANAGER_EXTERNAL_URL}'
- "--config.file=/etc/alertmanager/alertmanager.yml"
- "--storage.path=/alertmanager"
- "--web.external-url=${ALERTMANAGER_EXTERNAL_URL}"
restart: unless-stopped
expose:
- 8004
Expand All @@ -341,6 +350,27 @@ services:
networks:
- prometheus

nginx:
image: nginx:latest
# restart: always
container_name: nginx
ports:
- 80:80
volumes:
- ./nginx/prod.conf:/etc/nginx/nginx.conf
- ~/dist:/var/www/dist
- ./nginx/logs:/var/log/nginx
networks:
- app-network
depends_on:
- novamusic-user
- novamusic-track
- novamusic-artist
- novamusic-album
- novamusic-playlist
- novamusic-csat
- novamusic-genre

volumes:
postgres-volume:
minio-volume:
Expand Down
2 changes: 1 addition & 1 deletion docker/nginx/dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pid /var/run/nginx.pid;


events {
worker_connections 1024;
worker_connections 1024;
}


Expand Down
130 changes: 130 additions & 0 deletions docker/nginx/prod.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
worker_processes 1;

pid /var/run/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" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

sendfile on;
tcp_nopush on;

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=novamusic_cache:15m max_size=2g inactive=60s use_temp_path=off;

gzip on;
gzip_types text/plain text/css text/javascript text/xml application/json application/javascript image/svg;

upstream user_service {
server novamusic-user:8080;
}

upstream track_service {
server novamusic-track:8080;
}

upstream album_service {
server novamusic-album:8080;
}

upstream playlist_service {
server novamusic-playlist:8080;
}

upstream artist_service {
server novamusic-artist:8080;
}

upstream genre_service {
server novamusic-genre:8080;
}

upstream csat_service {
server novamusic-csat:8080;
}

server {
listen 80;
server_name novamusic;

return 301 https://nova-music.ru$request_uri;;
}

server {
listen 443 default_server ssl;
server_name novamusic;

http2 on;
http2_max_concurrent_streams 128;
keepalive_requests 1000;

ssl_certificate /etc/ssl/nova-music.ru/fullchain.pem;
ssl_certificate_key /etc/ssl/nova-music.ru/privkey.pem;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256';

add_header Host $http_host;
add_header Origin $http_origin;
add_header X-Real-IP $remote_addr;
add_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header X-Forwarded-Proto $scheme;
add_header Content-Type $http_content_type;

location /api/v1/users {
proxy_pass http://user_service/api/v1/users;
}

location /api/v1/auth {
proxy_pass http://user_service/api/v1/auth;
}

location /api/v1/health {
proxy_pass http://user_service/api/v1/health;
}

location /api/v1/tracks {
proxy_pass http://track_service/api/v1/tracks;
}

location /api/v1/albums {
proxy_pass http://album_service/api/v1/albums;
}

location /api/v1/playlists {
proxy_pass http://playlist_service/api/v1/playlists;
}

location /api/v1/artists {
proxy_pass http://artist_service/api/v1/artists;
}

location /api/v1/genres {
proxy_pass http://genre_service/api/v1/genres;
}

location /api/v1/csat {
proxy_pass http://csat_service/api/v1/csat;
}

location / {
proxy_cache novamusic_cache;
proxy_cache_valid 200 30m;

root /var/www/dist;
index index.html;
try_files $uri /index.html;
}
}
}

0 comments on commit ebf2020

Please sign in to comment.