user linzh linzh;
worker_processes 2;
events {
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
keepalive_timeout 30;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
open_file_cache max=65535 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
server_tokens off;
# 服务器列表
upstream backend {
server 127.0.0.1:8080 weight=1;
server 192.168.200.100 weight=1 fail_timeout=60s max_fails=2;
}
server {
listen 80;
# 以这些资源结尾的都直接返回,不走代理
location ~ .*\.(txt|css|js|jpg|jpeg|png|gif|svg|ttf|woff|woff2|otf|eot)$ {
# 从这个目录下读取
root /home/linzh/workspace/;
# 标记静态资源
add_header X static;
# 不记录访问日志
access_log off;
}
# 其他所有的都走代理
location / {
proxy_pass http://backend;
add_header X proxy;
}
}
}
网友评论