nginx.conf configuration file Detailed

Source: Internet
Author: User

nginx.conf configuration file Detailed

user root; #定义Nginx运行的用户和用户组worker_processes2; #nginx进程数, the recommended setting is equal to the total number of cores in the CPU. Worker_rlimit_nofile10240; #一个nginx进程打开的最多文件描述符数目, the theoretical value should be the maximum number of open files (System value Ulimit-N) divides the number of nginx processes, but the Nginx allocation request is not uniform, so it is recommended to Ulimitthe value of n remains the same. Error_log logs/Nginx_error.log crit; #全局错误日志定义类型, [Debug| info | Notice | Warn | Error |crit]events{use Epoll; #epoll模型是Linux2. High-performance network i/in kernel 6 or latero model, if run on FreeBSD above, use Kqueue model. Worker_connections2048;}      HTTP {include 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 "';    #日志格式设定 $remote _addr and $http _x_forwarded_for: Logs the IP address of the client.    $remote _user: Logs the client user name. $time _local: Record access time and time zone -/jul/ -: -:xx: on+0800. $request: Log The URL of the request with the HTTP protocol "GET/pa/img/home/logo-alipay-t.png http/1.1″.    $status: Record request status; Success is 200.    $body _bytes_sent: Record the size of the principal content sent to the client file.    $http _referer: Records are accessed from that page link (i.e., jump source).        $http _user_agent: Records information about the version of the client browser.    Client_header_buffer_size 16k; #上传文件大小限制 large_client_header_buffers432k;    #设定请求缓 # client_max_body_size 8m;    #设定请求缓 sendfile on; #开启高效文件传输模式, the sendfile instruction specifies whether Nginx calls the Sendfile function to output the file, and for normal applications to be set to ON, if it is used for downloading applications such as disk IO heavy load applications, can be configured to off to balance disk and network I/o processing speed, reducing the load on the system.        Note: If the picture does not appear normal, change this to off.     Tcp_nopush on;    #防止网络阻塞 Tcp_nodelay on;    #防止网络阻塞 Server_tokens off; Keepalive_timeout -; #长连接超时时间, Unit is seconds fastcgi_connect_timeout -; Fastcgi_send_timeout -; Fastcgi_read_timeout -;    Fastcgi_buffer_size 64k; Fastcgi_buffers464k;    Fastcgi_busy_buffers_size 128k;    Fastcgi_temp_file_write_size 128k; #FastCGI相关参数是为了改善网站的性能: Reduce resource usage and improve access speed.        The following parameters can be understood by literal means.  gzip on;   #开启gzip压缩输出 Gzip_min_length 1k; #最小压缩文件大小 gzip_buffers416k; #压缩缓冲区 Gzip_comp_level2; #压缩等级 gzip_types Text/plain application/x-javascript text/javascript text/css application/xml image/jpeg image/gif image/PNG; #压缩类型, the text is already included by default/html, so there is no need to write, write it will not be a problem, but there will be a warn.    Gzip_vary off; #限制ip访问服务 #server {# listen thedefault_server;# server_name _;#return 403; #} server {Listen8081;        server_name localhost; Location/{root HTML;        Index index.html index.htm; } #error_page404/404. html; # REDIRECT Server error pages to theStaticPage/50x.html # Error_page - 502 503 504/50x.html; Location= /50x.html {root html; }} include Vhost/*. conf;

Configuring Nginx slices and Js,css cache time settings

~ .*\. (gif|jpg|jpeg|png|bmp| ~ .*\. (JS|CSS)? ${expires 1h;}

nginx.conf configuration file 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.