Nginx configuration file nginx.conf detailed

Source: Internet
Author: User
Tags sendfile

1 #define user and user groups for Nginx run2 user www www;3 4 #the number of nginx processes, the recommended setting is equal to the total CPU core number. 5Worker_processes 8;6 7 #Global error log definition type, [Debug | info | notice | warn | error | crit]8error_log/var/log/nginx/Error.log info;9 Ten #Process Files Onepid/var/run/Nginx.pid; A  - #the maximum number of file descriptors opened by an nginx process, the theoretical value should be the maximum number of open files (System value ulimit-n) and the number of nginx processes, but the Nginx allocation request is not uniform, so the recommendation is consistent with the value of ulimit-n.  -Worker_rlimit_nofile 65535; the  - #Maximum number of operating modes and connections - Events - { + #Reference event model, use [kqueue | rtsig | epoll |/dev/poll | select | poll]; EPOLL model is a high-performance network I/O model in Linux 2.6 and above, if run on FreeBSD, Just use the Kqueue model.  - Use epoll; + #maximum number of connections per process (max connections = number of connections * Number of processes) AWorker_connections 65535; at } -  - #setting up an HTTP server - http - { -Include Mime.types;#file name extension and file type mapping table inDefault_type Application/octet-stream;#Default File Type - #charset utf-8; #默认编码 toServer_names_hash_bucket_size 128;#hash table size of server name +Client_header_buffer_size 32k;#upload file size limit -Large_client_header_buffers 4 64k;#Set Request Slow theClient_max_body_size 8m;#Set Request Slow *Sendfile on;#Open the efficient file transfer mode, the sendfile instruction specifies whether Nginx calls the Sendfile function to output the file, for the normal application is set to ON, if used for downloading and other applications such as disk IO heavy load application, can be set to off to balance disk and network I/O processing speed, Reduce the load on the system. Note: If the picture does not appear normal, change this to off.  $AutoIndex on;#Open Directory list access, appropriate to download the server, the default shutdown. Panax NotoginsengTcp_nopush on;#Prevent network congestion -Tcp_nodelay on;#Prevent network congestion theKeepalive_timeout 120;#Long connection time-out, unit is seconds +  A #fastcgi related parameters are designed to improve the performance of the site: Reduce resource usage and improve access speed. The following parameters can be understood by literal means.  theFastcgi_connect_timeout 300; +Fastcgi_send_timeout 300; -Fastcgi_read_timeout 300; $ fastcgi_buffer_size 64k; $Fastcgi_buffers 464k; - fastcgi_busy_buffers_size 128k; - fastcgi_temp_file_write_size 128k; the  - #gzip Module SettingsWuyigzip on;#turn on gzip compression output theGzip_min_length 1k;#Minimum compressed file size -Gzip_buffers 4 16k;#Compression Buffers WuGzip_http_version 1.0;#compressed version (default 1.1, front End If squid2.5 please use 1.0) -Gzip_comp_level 2;#compression Level AboutGzip_types text/plain application/x-javascript text/css application/XML; $ #compression type, the default already contains text/html, so the following will not have to write, write up will not have a problem, but there will be a warn.  - gzip_vary on; - #limit_zone crawler $binary _remote_addr 10m; #开启限制IP连接数的时候需要使用 -  A upstream blog.ha97.com { + #Upstream load balancing, weight is a weight that can be defined according to machine configuration. The Weigth parameter represents weights, and the higher the weight, the greater the probability of being allocated.  theServer 192.168.80.121:80 weight=3; -Server 192.168.80.122:80 weight=2; $Server 192.168.80.123:80 weight=3; the } the  the #configuration of the virtual host the Server - { in     #Listening Port theListen 80; the     #domain names can have multiple, separated by spaces About server_name www.ha97.com ha97.com; the index index.html index.htm index.php; theroot/data/www/ha97; theLocation ~. *\. (php|php5)? $ +     { -Fastcgi_pass 127.0.0.1:9000; the Fastcgi_index index.php;Bayi include fastcgi.conf; the     } the     #Picture Cache time Settings -Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $ -     { the expires 10d; the     } the     #JS and CSS cache time settings theLocation ~. *\. (js|CSS)? $ -     { the expires 1h; the     } the     #Log format Settings94Log_format Access'$remote _addr-$remote _user [$time _local] "$request"' the     '$status $body _bytes_sent "$http _referer"' the     '"$http _user_agent" $http _x_forwarded_for'; the     #define access logs for this virtual host98access_log/var/log/nginx/ha97access.log access; About  -     #Enable reverse proxy for "/"101Location/ {102Proxy_pass http://127.0.0.1:88;103 proxy_redirect off;104Proxy_set_header x-real-IP $remote _addr; the     #Backend Web server can obtain the user real IP via x-forwarded-for106Proxy_set_header x-forwarded-For $proxy _add_x_forwarded_for;107     #The following are some of the reverse proxy configurations, optional. 108 proxy_set_header Host $host;109Client_max_body_size 10m;#maximum number of single-file bytes allowed for client requests theClient_body_buffer_size 128k;#The maximum number of bytes requested by the buffer agent to buffer the client,111Proxy_connect_timeout 90;#Nginx-to-backend server connection time-out (proxy connection timed out) theProxy_send_timeout 90;#back-end server data backhaul time (proxy send timeout)113Proxy_read_timeout 90;#back-end server response time after successful connection (agent receive timeout) theProxy_buffer_size 4k;#Setting the proxy server (nginx) buffer size to hold user header information theProxy_buffers 4 32k;#proxy_buffers Buffer, the average Web page is set below 32k theProxy_busy_buffers_size 64k;#buffer size under high load (proxy_buffers*2)117 proxy_temp_file_write_size 64k;118     #Setting the cache folder size, larger than this value, will be passed from the upstream server119     } - 121     #set the address to view nginx status122Location/Nginxstatus {123 stub_status on;124 Access_log on; theAuth_basic"Nginxstatus";126Auth_basic_user_file conf/htpasswd;127     #the contents of the htpasswd file can be generated using the HTPASSWD tools provided by Apache.  -     }129  the     #local static and dynamic separation reverse proxy configuration131     #all JSP pages are processed by tomcat or resin theLocation ~. (jsp|jspx|Do )? $ {133 proxy_set_header Host $host;134Proxy_set_header x-real-IP $remote _addr;135Proxy_set_header x-forwarded-For $proxy _add_x_forwarded_for;136Proxy_pass http://127.0.0.1:8080;137     }138     #all static files are read directly by Nginx without Tomcat or resin139Location ~. *. (htm|html|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|ppt|pdf|xls|mp3|wma) $ $ {expires 15d;}141Location ~. *. (js|CSS)? $142 {expires 1h;}143 }144}

Nginx configuration file nginx.conf detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.