随笔分类 - nginx
摘要:安装完php php-fpm nginx 后访问php出现file not found错误,html就没问题配置文件server 段如下server { listen 80; server_name 192.168.1.11; root /home/www; location ~ .*\.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index inde...
阅读全文
摘要:cd ~wget -S https://github.com/agentzh/echo-nginx-module/archive/master.zipmv master echo-nginx-module-master.zipunzip echo-nginx-module-master.zipcd ..cd nginx-1.4.2./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --user=www --group=www --add-module=/root/
阅读全文
摘要:有这样的需求,客户上传图片,覆盖以前的图片,因为客户可能会频繁的换图片,上传覆盖完后,页面会自动请求刚才的图片,图片已经换掉,但是url并没有换,因为图片名字没改。因为更新的图要及时显示所以这个目录里的图片过期时间是location ~ .*\path\.(jpg|png|jpeg)${ expires 0;}但是并没有出现更新,浏览器依然会用本地的缓存。抓包发现,浏览器发现图片过期并发送了请求带有If-Modified-Since,得到的是304且Last-Modified时间没变,也就是说nginx说此图片没有更改,浏览器就用本地缓存了。但是通过stat命令发现此图片...
阅读全文
摘要:在nginx里的ngx_tr_t结构是字符串定义如下typedef struct { size_t len; u_char *data;}ngx_str_t;在给这样的结构体赋值的时候,nginx常用ngx_string(),这其实是个宏,如下#define ngx_string(str) { sizeof(str) - 1, (u_char *) str }当要建一个ngx_str_t类型的字符串,正确的做法是ngx_str_t mystr = ngx_string("hello");因为sizeof(str) - 1赋给len,sizeof()计算字符串长度会...
阅读全文
摘要:修改src/http/ngx_http_header_filter_module.c找到下面两行:static char ngx_http_server_string[] = "Server: nginx" CRLF;static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF;将其修改为:static char ngx_http_server_string[] = "Server: nginx" CRLF;static char ngx_http_serv
阅读全文
摘要:在nginx中有几个关于uri的变量,包括$uri $request_uri $document_uri,下面看一下他们的区别 :$request_uri: /stat.php?id=1585378&web_id=1585378$uri /stat.php$document_uri: /stat.php$args #这个变量等于请求行中的参数。$content_length #请求头中的Content-length字段。$content_type #请求头中的Content-Type字段。$document_root #当前请求在root指令中指定的值。$host #请求主机头字段,否
阅读全文
摘要:user root;worker_processes 4;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;worker_rlimit_nofile 327680;events { worker_connections 327680; use epoll;}http { include mime.types; default_type application/...
阅读全文
摘要:log_format main '$remote_addr - $remote_user $time_local "$request_method http://$host$request_uri HTTP/1.1" $status $bytes_sent "$http_referer" "$http_user_agent" TCP_HIT:NONE $request_time';log_format miss '$remote_addr - $remote_user $time_local "$re
阅读全文
摘要:linux内核配置有一项tcp_keepalive_time,即tcp的保活定时器。当网络上两个建立连接的进程都没有数据向对方发送的时候,tcp会隔段时间发送一次保活数据,以保持连接,间隔时间就是tcp_keepalive_time设置的。默认是7200秒。在优化web服务器时,应该将数值设置的小一点,当客户关机,崩溃的时候可以更快的发现,而没必要等待2个小时才察觉,这样可以更快的清理无效的连接。http的keepalive : 默认http服务器在完成一个http响应以后会关闭这个连接,设置此项以后会保活一段时间,继续用此连接继续接受客户的请求。这样有效的减少了系统建立tcp连接的开销,但是
阅读全文
摘要:安装sudo yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel sudo vim /etc/sysctl.conffs.file-max = 999999net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_keepalive_time = 600net.ipv4.tcp_fin_timeout = 30net.ipv4.tcp_max_tw_buckets = 5000net.ipv4.ip_local_port_range = 1024 61000net..
阅读全文
浙公网安备 33010602011771号