nginx配置文件nginx.conf中文注释说明

2019-10-17 21:06:36王旭

 
 #压缩类型,默认就已经包含text/html,所以下面就不用再写了,写上去也不会有问题,但是会有一个warn。
 gzip_vary on;
 #limit_zone crawler $binary_remote_addr 10m; #开启限制IP连接数的时候需要使用

 upstream qianyunlai.com {
  #upstream的负载均衡,weight是权重,可以根据机器配置定义权重。weigth参数表示权值,权值越高被分配到的几率越大。
  server 192.168.80.121:80 weight=3;
  server 192.168.80.122:80 weight=2;
  server 192.168.80.123:80 weight=3;
 }

 #虚拟主机的配置
 server {

  #监听端口
  listen 80;
  
  #域名可以有多个,用空格隔开
  server_name www.qianyunlai.com qianyunlai.com;
  index index.html index.htm index.php;
  root /data/www/qianyunlai;

  location ~ .*.(php|php5)?$ {
   fastcgi_pass 127.0.0.1:9000;
   fastcgi_index index.php;
   include fastcgi.conf;
  }

  #图片缓存时间设置
  location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ {
   expires 10d;
  }

  #JS和CSS缓存时间设置
  location ~ .*.(js|css)?$ {
   expires 1h;
  }

  #日志格式设定
  log_format access '$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/qianyunlai.log access;

  #对 "/" 启用反向代理
  location / {
   proxy_pass http://127.0.0.1:88;
   proxy_redirect off;
   proxy_set_header X-Real-IP $remote_addr;
   
   #后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   
   #以下是一些反向代理的配置,可选。
   proxy_set_header Host $host;
   client_max_body_size 10m; #允许客户端请求的最大单文件字节数
   client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数,
   proxy_connect_timeout 90; #nginx跟后端服务器连接超时时间(代理连接超时)
   proxy_send_timeout 90; #后端服务器数据回传时间(代理发送超时)
   proxy_read_timeout 90; #连接成功后,后端服务器响应时间(代理接收超时)