Skip to content

Instantly share code, notes, and snippets.

@vmlive
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vmlive/10022016 to your computer and use it in GitHub Desktop.
Save vmlive/10022016 to your computer and use it in GitHub Desktop.
Nginx镜像配置文件
user nginx nginx;
worker_processes 8;
error_log /var/log/nginx/error.log crit;
pid /var/run/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
charset utf-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
client_body_buffer_size 512k;
proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
proxy_temp_path /var/lib/nginx/proxy_temp;
upstream backend_server {
server 192.168.17.151:8080 weight=1 max_fails=2 fail_timeout=30s;
# server 192.168.17.152:8080 weight=1 max_fails=2 fail_timeout=30s;
}
server {
listen 80;
server_name web01.ysten.com 192.168.17.150;
index index.html index.php;
root /var/www;
set $index 'index.html';
set $store_file $request_filename;
if ($uri ~ /$ ){
set $store_file $request_filename$index;
rewrite (.*) $1index.html last;
}
location / {
index index.html;
proxy_store on;
proxy_temp_path /cache/temp;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Via "s9/nginx";
proxy_store_access user:rw group:rw all:rw;
if ( !-e $store_file ) {
proxy_pass http://backend_server;
}
}
}
log_format access '$remote_addr - $remote_user [$time_local] "$request"'
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for "$request_time" ';
access_log /var/log/nginx/access.log access;
#$upstream_cache_status表示资源缓存的状态,有HIT MISS EXPIRED三种状态
add_header X-Cache $upstream_cache_status;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment