|
|
|
worker_processes auto;
|
|
|
|
worker_cpu_affinity auto;
|
|
|
|
|
|
|
|
error_log /var/log/nginx/error.log;
|
|
|
|
pid /var/run/nginx.pid;
|
|
|
|
|
|
|
|
#daemon off;
|
|
|
|
events {
|
|
|
|
worker_connections 1024;
|
|
|
|
}
|
|
|
|
|
|
|
|
http {
|
|
|
|
# rewrite_log on;
|
|
|
|
include mime.types;
|
|
|
|
default_type application/json;
|
|
|
|
access_log /var/log/nginx/access.log;
|
|
|
|
sendfile on;
|
|
|
|
# tcp_nopush on;
|
|
|
|
keepalive_timeout 3;
|
|
|
|
# tcp_nodelay on;
|
|
|
|
# gzip on;
|
|
|
|
client_max_body_size 1m;
|
|
|
|
proxy_cache_path ./cache/ keys_zone=public_api_cache:1m;
|
|
|
|
|
|
|
|
server {
|
|
|
|
listen 8080 default_server;
|
|
|
|
server_name _;
|
|
|
|
|
|
|
|
error_page 400 = @400;
|
|
|
|
location @400 { return 400 '{"status":400,"message":"Bad request"}\n'; }
|
|
|
|
|
|
|
|
error_page 401 = @401;
|
|
|
|
location @401 { return 401 '{"status":401,"message":"Unauthorized"}\n'; }
|
|
|
|
|
|
|
|
error_page 403 = @403;
|
|
|
|
location @403 { return 403 '{"status":403,"message":"Forbidden"}\n'; }
|
|
|
|
|
|
|
|
error_page 404 = @404;
|
|
|
|
location @404 { return 404 '{"status":404,"message":"Resource not found"}\n'; }
|
|
|
|
|
|
|
|
error_page 405 = @405;
|
|
|
|
location @405 { return 405 '{"status":405,"message":"Method not allowed"}\n'; }
|
|
|
|
|
|
|
|
error_page 408 = @408;
|
|
|
|
location @408 { return 408 '{"status":408,"message":"Request timeout"}\n'; }
|
|
|
|
|
|
|
|
error_page 413 = @413;
|
|
|
|
location @413 { return 413 '{"status":413,"message":"Payload too large"}\n'; }
|
|
|
|
|
|
|
|
error_page 414 = @414;
|
|
|
|
location @414 { return 414 '{"status":414,"message":"Request URI too large"}\n'; }
|
|
|
|
|
|
|
|
error_page 415 = @415;
|
|
|
|
location @415 { return 415 '{"status":415,"message":"Unsupported media type"}\n'; }
|
|
|
|
|
|
|
|
error_page 426 = @426;
|
|
|
|
location @426 { return 426 '{"status":426,"message":"HTTP request was sent to HTTPS port"}\n'; }
|
|
|
|
|
|
|
|
error_page 429 = @429;
|
|
|
|
location @429 { return 429 '{"status":429,"message":"API rate limit exceeded"}\n'; }
|
|
|
|
|
|
|
|
error_page 495 = @495;
|
|
|
|
location @495 { return 495 '{"status":495,"message":"Client certificate authentication error"}\n'; }
|
|
|
|
|
|
|
|
error_page 496 = @496;
|
|
|
|
location @496 { return 496 '{"status":496,"message":"Client certificate not presented"}\n'; }
|
|
|
|
|
|
|
|
error_page 497 = @497;
|
|
|
|
location @497 { return 497 '{"status":497,"message":"HTTP request was sent to mutual TLS port"}\n'; }
|
|
|
|
|
|
|
|
error_page 500 = @500;
|
|
|
|
location @500 { return 500 '{"status":500,"message":"Server error"}\n'; }
|
|
|
|
|
|
|
|
error_page 501 = @501;
|
|
|
|
location @501 { return 501 '{"status":501,"message":"Not implemented"}\n'; }
|
|
|
|
|
|
|
|
error_page 502 = @502;
|
|
|
|
location @502 { return 502 '{"status":502,"message":"Bad gateway"}\n'; }
|
|
|
|
|
|
|
|
|
|
|
|
location / {
|
|
|
|
index index.html;
|
|
|
|
root /var/www/html;
|
|
|
|
try_files $uri $uri/ /index.html;
|
|
|
|
}
|
|
|
|
|
|
|
|
location /api/public {
|
|
|
|
add_header "Access-Control-Allow-Origin" *;
|
|
|
|
add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD, DELETE";
|
|
|
|
add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
|
|
|
|
add_header X-Cache-Status $upstream_cache_status;
|
|
|
|
|
|
|
|
proxy_cache public_api_cache;
|
|
|
|
proxy_cache_valid 200 8s;
|
|
|
|
default_type application/json;
|
|
|
|
proxy_pass http://backend:3000;
|
|
|
|
}
|
|
|
|
|
|
|
|
location /api {
|
|
|
|
default_type application/json;
|
|
|
|
proxy_pass http://backend:3000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|