Nginx 性能优化

Scroll Down

keepalive 优化吞吐量

http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive

upstream http_backend {
    server 127.0.0.1:8080;
    # 存活数量 
    keepalive 32;
}

server {
    ...

    location /http/ {
        proxy_pass http://http_backend;
        proxy_http_version 1.1;
	# 这里别忘了重置 Header中的 Connection 
        proxy_set_header Connection "";
        ...
    }
}

静态资源缓存

location / {
     root html;
     # 过期时间 1小时, 支持 s,h
     expires 1h;
     index index.html index.htm;
}

具体还可参照 Nginx 官网配置跟多详细信息
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#expires
image.png