Nginx. conf

Source: Internet
Author: User
# Running user # user nobody; # Number of enabled processes <= number of CPUs worker_processes 1; # saving location of error logs # error_log logs/error. log; # error_log logs/error. log notice; # error_log logs/error. log Info; # process number SAVING file # PID logs/nginx. PID; # Wait For Event Events {# enable performance improvement in Linux # The Event Response Mode is efficient poll mode use epoll; # (additional instructions for using the epoll I/O model: similar to Apache, nginx has different event models for different operating systems. A) standard event models select and poll are standard event models. If the current system does not have a more effective method, nginx will select or pollb) Efficient event model kqueue: Used in FreeBSD 4.1 +, OpenBSD 2.9 +, netbs D 2.0 and MacOS X. Using a dual-processor MacOS X System Using kqueue may cause kernel crashes. Epoll: Used in Linux kernel version 2.6 and later. /Dev/poll: Used in Solaris 7 11/99 +, HP/UX 11.22 + (eventport), IRIX 6.5.15 +, and Tru64 UNIX 5.1a +. Eventport: Used in Solaris 10. to prevent kernel crash, install a security patch.) # maximum number of connections of each process (maximum connections = number of connections X number of processes) # This command indicates the maximum number of file descriptors opened by an nginx process. The theoretical value should be the maximum number of opened files. # The number of parts (ulimit-N) is different from the number of nginx processes, however, nginx allocation requests are not so uniform, so it is best to keep them consistent with the ulimit-N value. # Currently, the number of files opened in the Linux 2.6 kernel is 65535, and worker_rlimit_nofile should be set to 65535. # This is because the allocation of requests to processes during nginx scheduling is not so balanced, so if you enter 10240, when the total concurrency reaches 3-4, 10240, there may be more than processes, the error 502 is returned. Worker_connections 1024;} HTTP {# file extension and file type ing table include mime. types; # default file type default_type application/octet-stream; # The log file output format is set globally # log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request"' # '$ Status $ body_bytes_sent "$ http_referer "' # '"$ http_user_agent" "$ http_x_forwarded_for "'; # request log storage location # access_log logs/access. log main; # Set the Request Buffer client_header_buffer_size 1 K; large_client_header_buffers 4 4 K; # Open the sendfile on; tcp_nopush on; # keepalive_timeout 0; # keepalive timeout keepalive_timeout 65; # control the client file size to client_max_body_size 8 m; # Open gzip compression gzip on; # obtain the original user's IP address map $ http_x_forwarded_for $ clientrealip {"" $ remote_addr ;~ ^ (? P <firstaddr> [0-9 \.] + ),?. * $ Firstaddr; }## restrict limit_conn_zone $ clientrealip zone = totalconnlimitzone: 20 m; limit_conn totalconnlimitzone 50; limit_conn_log_level notice; # limit_req_zone $ clientrealip zone = connlimitzone: 20 m rate = 10R/s; # limit_req zone = connlimitzone burst = 10 nodelay; limit_req_log_level notice; # Avoid 502fastcgi_buffers 8 128 K; send_timeout 60; # Set the Server list of Server Load balancer upstream mydomainats {# weigth Parameter Indicates the weight value. The higher the weight value, the higher the probability of being allocated. # indicates the percentage of request distribution. The default value is 1. # The max_fails parameter indicates a maximum of three failures # The fail_timeout parameter indicates the number of seconds after the request fails not to be accessed (10 s by default) server 127.0.0.1: 8081 Weight = 1 max_fails = 3 fail_timeout = 20 s; server 127.0.0.1: 8080 Weight = 2 max_fails = 3 fail_timeout = 20 s;} server {# listener port listen 80 for nginx; # IP address filtered by nginx or multiple spaces in the domain name SERVER_NAME 127.0.0.1 www.baidu.com; # character charset UTF-8; # prevent crawler if ($ http_user_agent ~ * "Qihoobot | baiduspider | googlebot-mobile | googlebot-image | mediapartners-Google | adsbot-Google | feedfetcher-Google | Yahoo! Slurp | Yahoo! Slurp China | youdaobot | sosospider | sogou spider | sogou web spider | msnbot | ia_archiver | tomato bot ") {return 403 ;} # view nginx real-time Status Location/status {# configuration verification information auth_basic "prompt information"; # username and password save address auth_basic_user_file/usr/local/nginx/CONF/htpasswd; # monitoring module stub_status on; # disable log access_log off;} # static file location ~ *\. (JPG | GIF | PNG | SWF | FLV | WMA | WMV | ASF | MP3 | MMF | zip | RAR) $ {# expires 30d; (expiration time, 30 days, can be adjusted in a proper amount) Root/web/www/html/;} All filters that end with .html must verify location ~ \. Html $ {auth_basic "restricted"; auth_basic_user_file/usr/local/nginx/CONF/htpasswd; access_log off;} # All proxy locations following the/2.0 directory ^ ~ /2.0/{## a maximum of five queues. Since 10 requests and 5 queues are processed per second, you can send up to 15 requests at a time, if there are more, error 503 is returned. limit_req zone = connlimitzone burst = 5 nodelay; proxy_pass http: // mypolicats; proxy_redirect off; # retain the Domain Name Information of the client request proxy_set_header host $ host; # retain the real IP address of the client request for certain access statistics: proxy_set_header X-real-IP $ remote_addr; proxy_set_header X-forwarded-for $ proxy_add_x_forwarded_for; client_max_body_size 10 m; client_body_buffer_size 128 K; proxy _ Connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; # Set the buffer size proxy_buffer_size 4 K for the proxy server (nginx) to save user header information; # proxy_buffer, if the average web page is below 32 K, in this way, set proxy_buffers 4 32 K; # proxy_buffers * 2) proxy_busy_buffers_size 64 K under high load; # Set the cache folder size, which is greater than this value, if the size of the file downloaded from the upstream server exceeds the size set by this parameter, nginx will first write the file to the temporary directory? (The default value is ???? Nginx? Under the installation directory/proxy_temp directory) proxy_temp_file_write_size 64 K;} disable all. txt files # location ~ /\. TXT {# deny all ;#}# another virtual host using mix of IP-, name-, and port-based configuration server {# multiple listeners # Listen localhost: 8666; # host name # SERVER_NAME liulj2576; # Web file path # Root E:/portal; # default homepage # index homepage.html; # location/{## local variables # Root E: /portal; # index homepage.html ;#}# https server https ssl encryption server ## server {# listen 443; # SERVER_NAME localhost; # SSL on; # ssl_certificate cert. PEM; # ssl_ce Rtificate_key cert. Key; # ssl_session_timeout 5 m; # ssl_protocols SSLv2 SSLv3 tlsv1; # ssl_ciphers all :! ADH :! Export56: RC4 + RSA: + high: + medium: + low: + SSLv2: + exp; # ssl_prefer_server_ciphers on; # location/{# Root HTML; # index index.html index.htm; #}#}}

 

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.