NGINX-VHOST-配置文件

NGINX VHOST 配置:

server {
  listen       80 ;
  server_name  domain.com www.domain.com;
  root    /data/wwwroot/;
  index   index.html index.htm index.php;

  location / {
    if (!-e $request_filename) {
      rewrite ^(.*)$ /index.php$1 last;
    }
  }
  location ~ .*\.php(\/.*)*$ {
    include fastcgi.conf;
    set $path_info "";
    set $real_script_name $fastcgi_script_name;
    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
    set $real_script_name $1;
    set $path_info $2;
    }
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_param  PATH_INFO  $path_info;
    fastcgi_param  SCRIPT_NAME     $fastcgi_script_name;
    fastcgi_param  SCRIPT_FILENAME   $document_root$real_script_name;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 256 16k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
   #This file is present on Debian systems..
    include fastcgi_params;
    }
  location ~ .*\.(gif|jpg|jpeg|png||png|bmp)$ {
        expires 1d;
  }
  access_log /usr/local/nginx/logs/www_domain.log combined;
 }

NGINX PROXY 配置:

upstream  backend  {
  server   127.0.0.1:8080  max_fails=3  fail_timeout=30s;
}

server {
  listen 80;
  server_name work.niknk.com ;
location / {
  proxy_pass http://backend;
  proxy_cache cache001;
  proxy_cache_key $host$uri$is_args$args; 
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_cache_valid 200 304 12h;
  expires 2d;
}
location ~ .*\.(php|jsp|cgi|asp|aspx|flv|swf|xml)?$ {
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $remote_addr;
  proxy_pass http://backend;
}
location ~ /purge(/.*) {
  proxy_cache_purge cache001 $host$1$is_args$args;
}
  access_log off;
}

配置文件下载地址:
– VHOST.CONF
– PROXY.CONF


补充:

NGINX-UPSTREAM配置

点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注