In Nginx configuration details, there will be a lot of issues that you don't understand When configuring Nginx. In fact, sometimes you only need to change your mind to find more ways to solve the problem. Official configuration example: wiki. nginx. orgNginxFullExample650) this. alt copy code srccdn. verydemo
In Nginx configuration details, there will be a lot of issues that you don't understand When configuring Nginx. In fact, sometimes you only need to change your mind to find more ways to solve the problem. Official configuration example: http://wiki.nginx.org/NginxFullExample 650) this. width = 650; "alt =" "src =" http://cdn.verydemo
NginxConfigurationDetails
NginxConfigurationThere will be a lot of things you don't understand. In fact, sometimes you only need to change the way of thinking to find more ways to solve the problem. OfficialConfigurationExample: http://wiki.nginx.org/NginxFullExample
650) this. width = 650; "alt =" "src =" http://cdn.verydemo.com/upload/112_9/13516763303830.gif "/>
# Running user
User nobody;
# Start a process
Worker_processes 4;
# Global error logs and PID documentation [debug | info | notice | warn | error | crit]
Error_log logs/error. log notice;
Pid logs/Nginx. pid;
# Working mode and maximum number of connections
Events {
# Working modes: # use [kqueue | rtsig | epoll |/dev/poll | select | poll];
Use epoll;
Worker_connections 1024;
}
# Set the http server and use its reverse proxy function to provide Load Balancing support
Http {
# Set the mime type
Include conf/mime. types;
Default_type application/octet-stream;
# Set the log format
Log_format main '$ remote_addr-$ remote_user [$ time_local]'
'"$ Request" $ status $ bytes_sent'
'"$ Http_referer" "$ http_user_agent "'
'"$ Gzip_ratio "';
Log_format download '$ remote_addr-$ remote_user [$ time_local]'
'"$ Request" $ status $ bytes_sent'
'"$ Http_referer" "$ http_user_agent "'
'"$ Http_range" "$ sent_http_content_range "';
# Set Request Buffer
Client_header_buffer_size 1 k;
Large_client_header_buffers 4 4 k;
# Enable the gzip Module
Gzip on;
Gzip_min_length 1100;
Gzip_buffers 4 8 k;
Gzip_types text/plain;
Output_buffers 1 32 k;
Post pone_output 1460;
# Setting access log
Access_log logs/access. log main;
Client_header_timeout 3 m;
Client_body_timeout 3 m;
Send_timeout 3 m;
Sendfile on; # Use of sendfile () activated or disabled by the command.
Tcp_nopush on;
Tcp_nodelay on;
Keepalive_timeout 65;
# Set the Server list of Server Load balancer
Upstream mysvr {
# The weigth parameter indicates the weight. A higher weight indicates a higher probability of being assigned.
# Enable port 3128 for Squid on the local machine
Server 192.168.8.1: 3128 weight = 5;
Server 192.168.8.2: 80 weight = 1;
Server 192.168.8.3: 80 weight = 6;
}
# Set Virtual Hosts
Server {
Listen 80;
Server_name 192.168.8.1 www.yejr.com;
Charset utf8;
# Set access logs for the current virtual host
Access_log logs/www.yejr.com. access. log main;
# If you access/img/*,/js/*,/css/* resources, you can directly obtain the local document without passing squid
# If there are many documents, this method is not recommended because the squid cache has better results.
Location ~ ^/(Img | js | css )/{
Root/data3/Html;
Expires 24 h;
}
# Enable Server Load balancer "/"
Location /{
Proxy_pass http: // mysvr;
Proxy_redirect off;
Proxy_set_header Host $ host;
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;
Proxy_buffer_size 4 k;
Proxy_buffers 4 32 k;
Proxy_busy_buffers_size 64 k;
Proxy_temp_file_write_size 64 k;
}
# Set the address for viewing Nginx status
Location/NginxStatus {
Stub_status on;
Access_log on;
Auth_basic "NginxStatus ";
Auth_basic_user_file conf/htpasswd;
}
# Error_page 404/404 .html;
# Location/404.html {
# Root/spool/www;
# Charset on;
# Source_charset koi8-r;
#}
# Location/old_stuff /{
# Rewrite ^/old_stuff/(. *) $/new_stuff/$1 permanent;
#}
# Location/download /{
# Valid_referers none blocked server_names * .example.com;
# If ($ invalid_referer ){
# Rewrite ^/http://www.example.com /;
# Return 403;
#}
# Rewrite_log on;
# Rewrite/download/*/mp3/*. any_ext to/download/*/mp3/*. mp3
# Rewrite ^/(download/. *)/mp3/(. *) \ .. * $/$1/mp3/ipv2.mp3 break;
# Root/spool/www;
# Autoindex on;
# Access_log/var/log/nginx-download.access_log download;
#}
# Location ~ * ^. + \. (Jpg | jpeg | gif) $ {
# Root/spool/www;
# Access_log off;
# Expires 30d;
#}
}
}
650) this. width = 650; "alt =" "src =" http://cdn.verydemo.com/upload/112_9/13516763303830.gif "/>
Note: The content of conf/htpasswd is generated using the htpasswd tool provided by apache.
View Nginx running status input address http: // 192.168.8.1/NginxStatus /. Enter the verification account password and you will see something similar to the following:
Active connections: 328
server accepts handled requests
9309 8982 28890
Reading: 1 Writing: 3 Waiting: 324
The first line indicates the number of active connections, and the third number in the third line indicates that Nginx is running.