Advertisement
Guest User

Untitled

a guest
Mar 12th, 2024
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. user nginx;
  2.  
  3. # you must set worker processes based on your CPU cores, nginx does not benefit from setting more than that
  4. worker_processes auto;
  5.  
  6. # number of file descriptors used for nginx
  7. # the limit for the maximum FDs on the server is usually set by the OS.
  8. # if you don't set FD's then OS settings will be used which is by default 2000
  9. worker_rlimit_nofile 100000;
  10.  
  11. # only log critical errors
  12. error_log /var/log/nginx/error.log crit;
  13.  
  14. pid /var/run/nginx.pid;
  15.  
  16. events {
  17. # determines how much clients will be served per worker
  18. # max clients = worker_connections * worker_processes
  19. # max clients is also limited by the number of socket connections available on the system (~64k)
  20. worker_connections 4000;
  21. }
  22.  
  23. #load_module modules/ngx_http_security_headers_module.so;
  24.  
  25. http {
  26.  
  27. include /etc/nginx/mime.types;
  28. default_type application/octet-stream;
  29. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  30. '$status $body_bytes_sent "$http_referer" '
  31. '"$http_user_agent" "$http_x_forwarded_for"';
  32.  
  33. # to boost I/O on HDD we can disable access logs
  34. access_log off;
  35. sendfile on;
  36.  
  37. # send headers in one piece, it is better than sending them one by one
  38. tcp_nopush on;
  39.  
  40. # don't buffer data sent, good for small data bursts in real time
  41. tcp_nodelay on;
  42.  
  43. # allow the server to close connection on non responding client, this will free up memory
  44. reset_timedout_connection on;
  45.  
  46. # request timed out -- default 60
  47. client_body_timeout 10;
  48.  
  49. # if client stop responding, free up memory -- default 60
  50. send_timeout 2;
  51.  
  52. # server will close connection after this time -- default 75
  53. keepalive_timeout 30;
  54.  
  55. # cache informations about FDs, frequently accessed files
  56. # can boost performance, but you need to test those values
  57. open_file_cache max=200000 inactive=20s;
  58. open_file_cache_valid 30s;
  59. open_file_cache_min_uses 2;
  60. open_file_cache_errors on;
  61.  
  62. server_tokens off;
  63. #hide_server_tokens on;
  64.  
  65. # Disable x-powered-by header
  66. proxy_hide_header X-Powered-By;
  67.  
  68. # Add x-content-type-options header
  69. add_header X-Content-Type-Options "nosniff";
  70.  
  71. # Add referrer-policy header
  72. add_header Referrer-Policy "origin";
  73.  
  74. # Add feature-policy header
  75. add_header Feature-Policy "geolocation none; unsized-media none;";
  76.  
  77. # limit the number of connections per single IP
  78. limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;
  79.  
  80. # limit the number of requests for a given session
  81. limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;
  82.  
  83. # if the request body size is more than the buffer size, then the entire (or partial)
  84. # request body is written into a temporary file
  85. client_body_buffer_size 128k;
  86.  
  87. # maximum number and size of buffers for large headers to read from client request
  88. large_client_header_buffers 10 512k;
  89.  
  90. server {
  91. listen 80;
  92. server_name localhost;
  93.  
  94. # client_max_body_size = SIZE LIMIT FOR REQUESTS, INITIAL VALUE WAS 20MB.
  95. client_max_body_size 500M;
  96.  
  97. gzip on;
  98. # proxy_max_temp_file_size 0;
  99.  
  100. location / {
  101. root /usr/share/nginx/html;
  102. index index.html;
  103. try_files $uri $uri/ /index.html;
  104. proxy_hide_header 'Cache-Control';
  105. add_header 'Cache-Control' "public, max-age=10";
  106. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
  107. # add_header 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
  108. }
  109.  
  110. error_page 500 502 503 504 /50x.html;
  111. location = /50x.html {
  112. root /usr/share/nginx/html;
  113. }
  114.  
  115. add_header X-Frame-Options "deny" always;
  116. # proxy_hide_header 'Cache-Control';
  117. # deny framing and clickjacking
  118.  
  119. # limit whole server
  120. # limit_conn conn_limit_per_ip 10;
  121. # limit_req zone=req_limit_per_ip burst=10 nodelay;
  122. }
  123. }
  124.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement