mirror of
https://github.com/nprasad2077/NBA_Go.git
synced 2026-09-22 05:55:13 +00:00
cache
This commit is contained in:
@@ -75,6 +75,7 @@ services:
|
|||||||
image: 'nginx:stable'
|
image: 'nginx:stable'
|
||||||
volumes:
|
volumes:
|
||||||
- './nginx/nginx.conf:/etc/nginx/nginx.conf:ro'
|
- './nginx/nginx.conf:/etc/nginx/nginx.conf:ro'
|
||||||
|
- nginx_cache:/var/cache/nginx
|
||||||
depends_on:
|
depends_on:
|
||||||
- api1
|
- api1
|
||||||
- api2
|
- api2
|
||||||
@@ -123,6 +124,7 @@ volumes:
|
|||||||
postgres_data: # New volume for Postgres
|
postgres_data: # New volume for Postgres
|
||||||
prometheus_data:
|
prometheus_data:
|
||||||
grafana_data:
|
grafana_data:
|
||||||
|
nginx_cache:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
api.network: null
|
api.network: null
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ services:
|
|||||||
image: 'nginx:stable'
|
image: 'nginx:stable'
|
||||||
volumes:
|
volumes:
|
||||||
- '/data/nba-go-config/nginx:/etc/nginx:ro'
|
- '/data/nba-go-config/nginx:/etc/nginx:ro'
|
||||||
|
- nginx_cache:/var/cache/nginx
|
||||||
depends_on:
|
depends_on:
|
||||||
- api1
|
- api1
|
||||||
- api2
|
- api2
|
||||||
@@ -84,6 +85,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
prometheus_data:
|
prometheus_data:
|
||||||
grafana_data:
|
grafana_data:
|
||||||
|
nginx_cache:
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
# api_network:
|
# api_network:
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,8 @@ events {
|
|||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
|
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=api_cache:10m max_size=100m inactive=5m;
|
||||||
|
|
||||||
upstream go_backend {
|
upstream go_backend {
|
||||||
server api1:5000;
|
server api1:5000;
|
||||||
server api2:5000;
|
server api2:5000;
|
||||||
@@ -17,6 +19,24 @@ http {
|
|||||||
access_log /dev/stdout;
|
access_log /dev/stdout;
|
||||||
error_log /dev/stderr;
|
error_log /dev/stderr;
|
||||||
|
|
||||||
|
location /api/ {
|
||||||
|
proxy_cache api_cache;
|
||||||
|
proxy_cache_valid 200 30s;
|
||||||
|
proxy_cache_key "$request_uri";
|
||||||
|
proxy_cache_use_stale error timeout updating;
|
||||||
|
add_header X-Cache-Status $upstream_cache_status;
|
||||||
|
|
||||||
|
proxy_pass http://go_backend;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection keep-alive;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_cache_bypass $http_upgrade;
|
||||||
|
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 / {
|
location / {
|
||||||
proxy_pass http://go_backend;
|
proxy_pass http://go_backend;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
|||||||
Reference in New Issue
Block a user