请参考官方:
http://wiki.nginx.org/HttpRewriteModule#Synopsis
关于缓存大小权限
error log 有如下日志:an upstream response is buffered to a temporary file,
注意:当临时文件提示没有权限写时,发发送给客户端只接收到的这部分数据。
fastcgi_buffer_size 512k; fastcgi_buffers 6 512k; fastcgi_busy_buffers_size 512k; fastcgi_temp_file_write_size 512k;
默认的vhost
listen 80 default_server; server_name _;
增加Nginx请求缓存
location =/test_oss/cgi_interface/get_rs_proxy_by_domain.php { add_header X-Location cae_data_cache; add_header X-Cached $upstream_cache_status; fastcgi_cache fcgi_cache; fastcgi_cache_key "$request_method$uri$is_args$arg_domain$arg_city"; fastcgi_cache_valid 200 3m; fastcgi_cache_min_uses 1; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_temp_path /tmp/ngx_fcgi_tmp; include fastcgi.conf; fastcgi_pass unix:/dev/shm/cae_webdev.socket; }
默认均匹配
location / { include fastcgi.conf; fastcgi_pass unix:/dev/shm/cae_webdev.socket; }
TCP相关
sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_requests 64; keepalive_timeout 10;
PHP HHVM容错配置
location ~ \.php$ { include fastcgi.conf; fastcgi_pass 127.0.0.1:9090; #for 500/502 error change it to php-fpm error_page 500 502 = @fallback_fpm; } location @fallback_fpm { include fastcgi.conf; fastcgi_pass unix:/dev/shm/cweb_php.socket; }
重定向配置
if (!-e $request_filename) { rewrite ^(.*)$ /index.php?$1 last; } try_files $uri /index.php$is_args$args;
- 注意尽量不要用if
- rewrite不改变当前$uri的值,也就是多个rewrite时,$uri的值始终只有初始一个
- try_files会修改全局变量$uri的值
- location是有顺序的,rewrite的优先级可以认为比location高
时间: 2024-10-17 04:05:26