12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- # user nginx;
- worker_processes auto;
- error_log /var/log/nginx/error.log warn;
- pid /var/run/nginx.pid;
- events {
- # The maximum number of connections that each worker process can handle simultaneously. The default is 512, but most systems have enough resources to support a larger number. The appropriate setting depends on the size of the server and the nature of the traffic, and can be discovered through testing.
- worker_connections 65535;
- # This directive allows a worker to accept many connections in the queue at a time. A queue in this context simply means a sequence of data objects waiting to be processed.
- multi_accept on;
- # With this directive worker processes will accept new connections by turn. Otherwise, all worker processes will be notified about new connections, and if volume of new connections is low, some of the worker processes may just waste system resources.
- accept_mutex on;
- # This directive determines how long a worker should wait before accepting a new connection. Once the accept_mutex is turned on, a mutex lock is assigned to a worker for a timeframe specified by the accept_mutex_delay . When the timeframe is up, the next worker in line is ready to accept new connections.
- accept_mutex_delay 200ms;
- # This directive specifies the method to process a connection from the client. We decided to set the value to epoll because we are working on a Ubuntu platform. The epoll method is the most effective processing method for Linux platforms.
- use epoll;
- # This specifies the number of events that NGINX will pass to the kernel.
- epoll_events 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 main;
- sendfile on;
- #tcp_nopush on;
- keepalive_timeout 65;
- #gzip on;
- server_names_hash_bucket_size 64;
- server_names_hash_max_size 512;
- server {
- listen 80 ;
- # root /opt/dist;
- root /opt/dist;
- index index.html index.htm index.nginx-debian.html;
- # MIME
- include /etc/nginx/mime.types;
- default_type application/octet-stream;
- # Display nginx Version number in error or http header may result in hacker to search for known vulnerability. Therefore, the version number should be removed for every http response.
- server_tokens "off";
- #charset utf-8;
- # This directive, by default, is disabled to allow small packets to wait for a specified period before they are sent at once. To allow all data to be sent at once, this directive is enabled.
- tcp_nodelay on;
- # Because we have enabled tcp_nodelay directive, small packets are sent at once. However, if you still want to make use of John Nagle’s buffering algorithm, we can also enable the tcp_nopush to add packets to each other and send them all at once.
- tcp_nopush on;
- # Defines a timeout for reading client request body. The timeout is set only for a period between two successive read operations, not for the transmission of the whole request body. If a client does not transmit anything within this time, the 408 (Request Time-out) error is returned to the client.
- client_body_timeout 12;
- # Defines a timeout for reading client request header. If a client does not transmit the entire header within this time, the 408 (Request Time-out) error is returned to the client.
- client_header_timeout 12;
- # This directive sets the buffer size for the request body. If you plan to run the webserver on 64-bit systems, you need to set the value to 16k. If you want to run the webserver on the 32-bit system, set the value to 8k.
- client_body_buffer_size 1M;
- # Similar to the previous directive, only instead it handles the client header size. For all intents and purposes, 1K is usually a decent size for this directive not unless you're sending mayopic stuff via header i.e permissions.
- client_header_buffer_size 1k;
- # The maximum number and size of buffers for large client headers.
- large_client_header_buffers 2 1k;
- # The maximum allowed size for a client request. If the maximum size is exceeded, then Nginx will spit out a 413 error or Request Entity Too Large.
- client_max_body_size 500M;
- # Defines the maximum size of an entry in the MIME types hash tables.
- types_hash_max_size 4096;
- # The first parameter sets a timeout during which a keep-alive client connection will stay open on the server side. The zero value disables keep-alive client connections. The optional second parameter sets a value in the “Keep-Alive: timeout=time” response header field. Two parameters may differ. The “Keep-Alive: timeout=time” header field is recognized by Mozilla and Konqueror. The default is 75 seconds.
- keepalive_timeout 120s;
- # Configure a number of requests to keep alive for a specific period of time. You can set the number of requests to 20 or 30.
- keepalive_requests 120;
- # if you want to disable keepalive connection for a specific group of browsers, use this directive.
- #keepalive_disable;
- #Sets a timeout for transmitting a response to the client. The timeout is set only between two successive write operations, not for the transmission of the whole response. If the client does not receive anything within this time, the connection is closed.
- send_timeout 75s;
- include /etc/nginx/general.conf;
- include /etc/nginx/security.conf;
- }
- }
|