http {
......省略配置
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
tcp_nodelay on;
server_tokens off;
.......省略配置
}
重启nginx /usr/local/webserver/nginx/bin/nginx -s reload
这是我的nginx+tomcat服务器上执行前后的对比结果
[root@localhost ~]# curl --head 127.0.0.1
HTTP/1.1 403 Forbidden
Server: nginx/0.8.46
Date: Fri, 11 Mar 2011 08:26:51 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 169
Connection: keep-alive
[root@localhost ~]# /usr/local/webserver/nginx/sbin/nginx -s reload
[root@localhost ~]# curl --head 127.0.0.1
HTTP/1.1 403 Forbidden
Server: nginx
Date: Fri, 11 Mar 2011 08:26:58 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 162
Connection: keep-alive
如果服务器跑的是nginx+php-fpm,这时候需要编辑php-fpm配置文件 如fcgi.conf、fastcgi.conf(要看你是什么配置文件名),久违的403报错,看看,有没有nginx版本泄露的信息:
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
改为fastcgi_param SERVER_SOFTWARE nginx;
记得平滑重启下 平滑重启:
/usr/local/webserver/nginx/sbin/nginx -s reload