nginx.conf 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. http {
  2. server {
  3. # server_name example.com;
  4. # ssl_certificate cert/example.com/ecc.cer;
  5. # ssl_certificate_key cert/example.com/ecc.key;
  6. # listen 8443 ssl http2;
  7. listen 8080;
  8. include api.conf;
  9. }
  10. # https://nginx.org/en/docs/http/ngx_http_core_module.html
  11. resolver 1.1.1.1 ipv6=off;
  12. resolver_timeout 10s;
  13. keepalive_timeout 60;
  14. keepalive_requests 2048;
  15. server_tokens off;
  16. underscores_in_headers on;
  17. # https://nginx.org/en/docs/http/ngx_http_ssl_module.html
  18. ssl_protocols TLSv1.2 TLSv1.3;
  19. ssl_ciphers TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-256-GCM-SHA384:TLS13-AES-128-GCM-SHA256:EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
  20. ssl_session_cache shared:SSL:30m;
  21. ssl_session_timeout 1d;
  22. ssl_prefer_server_ciphers on;
  23. # https://nginx.org/en/docs/http/ngx_http_limit_req_module.html
  24. limit_req_log_level warn;
  25. limit_req_zone $binary_remote_addr zone=reqip:16m rate=100r/s;
  26. limit_req zone=reqip burst=200 nodelay;
  27. # https://nginx.org/en/docs/http/ngx_http_log_module.html
  28. # separated by tab (\t)
  29. log_format log_proxy escape=none
  30. '02 ' # ver prefix
  31. '$time_iso8601 $_origin_id $_ver $remote_addr '
  32. '$_level $_switched $upstream_cache_status $request_time '
  33. '$request_length $bytes_sent '
  34. '$request_method $_url $status $_bodyhash $upstream_http_access_control_allow_origin '
  35. '$http_user_agent $_ref $_mode $_type'
  36. ;
  37. access_log logs/proxy.log log_proxy buffer=64k flush=1s;
  38. # https://nginx.org/cn/docs/http/ngx_http_proxy_module.html
  39. # 1MB = 8000key
  40. proxy_cache_path cache
  41. levels=1:2
  42. keys_zone=my_cache:32m
  43. max_size=20g
  44. inactive=6h
  45. use_temp_path=off
  46. ;
  47. proxy_http_version 1.1;
  48. proxy_ssl_server_name on;
  49. proxy_buffer_size 16k;
  50. proxy_buffers 4 32k;
  51. proxy_busy_buffers_size 64k;
  52. proxy_send_timeout 10s;
  53. lua_load_resty_core off;
  54. map $http_origin $_origin_id {
  55. '' 'mysite';
  56. include allowed-sites.conf;
  57. }
  58. }
  59. # https://nginx.org/en/docs/ngx_core_module.html
  60. events {
  61. worker_connections 4096;
  62. }