3.4.2.1. | 502 Bad Gateway error.log 提示: upstream sent too big header while reading response header from upstream? |
修改fastcgi配置
location ~ \.php$ {
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
。。。
。。。
}
|
nginx: [emerg] "proxy_pass" cannot have URI part in location given by regular expression, or inside named location, or inside "if" statement, or inside "limit_except" block in /etc/nginx/conf.d/www.mydomain.com.conf:25 nginx: configuration file /etc/nginx/nginx.conf test failed
在location,if中使用证则匹配proxy_pass末尾不能写/
if ($request_uri ~* "^/info/{cn|tw}/{news|info}/\d\.html") {
proxy_pass http://info.example.com/;
break;
}
location ~ ^/info/ {
proxy_pass http://info.example.com/;
break;
}
proxy_pass http://info.example.com/; 改为 proxy_pass http://info.example.com; 可以解决
如果用户Cookie信息没有经过 proxy_pass 传递给最终服务器,SESSION信息将丢失,解决方案
proxy_set_header Cookie $http_cookie;
配置 worker_rlimit_nofile 参数即可
user nginx; worker_processes 8; worker_rlimit_nofile 65530;
配置 ulimit 也能达到同样效果,但我更喜欢 worker_rlimit_nofile 因为它仅仅作用于nginx,而不是全局配置。
server_name www.example.com www.example.net www.example.org;
下来SSI标签无论你使用那个域名访问,输出永远是server_name的第一域名www.example.com
<!--#echo var="SERVER_NAME"-->
需要通过SERVER_NAME判定展示不同结果时需要注意。
下面的例子是 Document root 是 /www/netkiller.com/m.netkiller.com, 我们需要 /www/netkiller.com/www.netkiller.com 中的资源。
server {
listen 80;
server_name m.netkiller.com;
charset utf-8;
access_log /var/log/nginx/m.netkiller.com.access.log;
error_log /var/log/nginx/m.netkiller.com.error.log;
location / {
root /www/netkiller.com/m.netkiller.com;
index.html
}
location /module {
root /www/netkiller.com/www.netkiller.com;
}
}
server {
listen 80;
server_name m.netkiller.com;
charset utf-8;
access_log /var/log/nginx/m.netkiller.com.access.log;
error_log /var/log/nginx/m.netkiller.com.error.log;
location / {
root /www/netkiller.com/m.netkiller.com;
index.html
}
location ^~ /module/ {
root /www/netkiller.com/www.netkiller.com;
}
}
上面的例子location /module 是指 /www/netkiller.com/www.netkiller.com + /module,如果 /www/netkiller.com/www.netkiller.com 目录下面没有 module 目录是出现404, error.log显示 "/www/netkiller.cn/www.netkiller.cn/module/index.html" failed (2: No such file or directory)