减少Linux服务器的TIME_WAIT连接

分类:Kernelvim /etc/sysctl.conf,如果不存在则新建此文件

net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.ip_local_port_range = 1024 65000

执行以下命令使配置生效:
/sbin/sysctl -p

各项解释如下:

继续阅读 »

Nginx:proxy_pass路径问题解决方案

在nginx中配置proxy_pass时,如果是按照^~匹配路径时,要注意proxy_pass后的url最后的/

当加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走
如果没有/,则会把匹配的路径部分也给代理走

location ^~ /blog/
{
    proxy_cache blog_cache;
    proxy_set_header Host blog.linuxany.com;
    proxy_pass http://blog.linuxany.com/;
}

如果请求的url是http://www.linuxany.com/blog/test.html
会被代理成http://blog.linuxany.com/test.html

继续阅读 »


返回顶部