Support NginxWiki-20110303.chm to download
Nginx more and more popular, but official wiki have too much time to chm[NginxWiki-20090731.chm], so I compiled the latest sync to the wiki into chm, available to the offline-read students who needed.
Download:
NginxWiki-20110303.chm.tar.gz
解决Nginx编译出错:cc1: warnings being treated as errors
这个就是说如果有警告,也认为是错误,解决办法就是去掉objs/makefile中 -Werror这样一段,重新make就ok了,特记之。
nginx/apache 中防止绑定别人恶意解析过来的域名
最近为了符合国家某某部门的需求,需要禁止别人而已解析非本站的域名到本站,需要做一些域名绑定的操作,故对公司各个项目做了域名绑定处理。
nginx
server {
listen 80 default;
root /dev/null;
location / {
return 404;
access_log off;
}
}
apache
# vhost.conf
<Virtualhost *:80>
ServerName joinus.jobkoo.com
ServerAlias wanmei.jobkoo.com,test.jobkoo.com,*.jobkoo.com
RewriteEngine on
# 只要不是下面列出的域名均报错指向error.html文件,这个文件并不存在,因此会报404
# 错误。正好符合国家要求
RewriteCond %{HTTP_HOST} !^joinus|wanmei|test|demo\.jobkoo\.com [NC]
RewriteRule ^/(.*) /error.html [L]
# 判断Port是否为443,不是的话跳转到443端口
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/?(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
DocumentRoot "/data/web/www"
</VirtualHost>
检测是否配置成功
curl –I domain
Nginx+php下用Content-Length替换chunk编码模式方法
1.修改nginx配置文件,gzip:off
2.php程序文件中,输出时加一个头参数
Header(“Content-lenth: $output_length\r\n”);
3.搞定!
没看过Nginx的源码,猜想了下Nginx的处理流程
1: if( gzip on ){
2: chunk;
3: }
4: else {
5: if( has content-lenth ) {
6: content-lenth;
7: }
8: else {
9: chunk
10: }
11: }