我有一台双四核 Centos 6.3 服务器,配备 32GB 内存。
我已经安装了 nginx 来提供静态文件,并将其作为后端 apache 的反向代理服务器。我使用的面板是 IspConfig 3.0.5.2。
一开始一切似乎都运行良好,但最近我意识到有些不对劲!Nginx 从错误的文档根目录提供服务。我浏览了 Google 和 Nginx 论坛,但找不到解决方案。我对配置文件进行了多次修改/更改/修正,并尝试通过 Nginx 日志进行调试,但毫无效果!
以下是我的配置文件和日志摘录。请帮我整理一下。
//文件/etc/nginx/nginx.conf
# For more information on configuration, see:
# * Official English Documentation: nginx. org/en/docs/
# * Official Russian Documentation: nginx. org/ru/docs/
user apache nginx;
worker_processes 8;
error_log /var/log/nginx/error.log warn;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
# allow long server names
server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
index index.html index.htm index.php;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format mukaanyes '$remote_addr - $remote_user [$time_local] '
'"$request" $host "$domain" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# access_log /var/log/ispconfig/httpd/$domain/access.log mukaanyes;
access_log /var/log/nginxaccess.log mukaanyes;
#access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
server_tokens off;
#keepalive_timeout 0;
keepalive_timeout 65;
#mukaanyes; Make adjustments to gzip module
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x$
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
include /etc/nginx/conf.d/*.conf;
}
// END /etc/nginx/nginx.conf
// 文件 /etc/nginx/conf.d/default.conf
server {
listen 80 default;
#server_name _;
server_name ~^(www\.)?(?P<domain>.+)$;
server_name_in_redirect off;
resolver 127.0.0.1;
root /var/www/$domain/web;
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|flv|mp3)$ {
access_log off;
expires 30d;
}
location / {
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
#included fcgid.conf instead
#fastcgi_param SERVER_NAME $domain; #avoid wrong doc_root, formerly was $host
# proxy_pass http://$host:82;
proxy_pass http://$domain:82;
#mukaanyes added proxy_redirect off
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host; #formerly was $host
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
// END /etc/nginx/conf.d/default.conf
// 文件 /etc/nginx/conf.d/fcgid.conf
#fastcgi.conf
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
// END /etc/nginx/conf.d/fcgid.conf
以下是日志文件的摘录,采用我的自定义格式“mukaanyes”
66.249.73.224 - - [10/Jul/2013:00:18:02 +0100] "GET /ne_demek/hatil HTTP/1.1" www,mankenresimleri,net "mankenresimleri,net" 404 4196 "-" "Mozilla/5.0 (兼容; Googlebot/2.1; +http://www.google.com/bot.html)“-”
/ne_demek/hatil 是针对 http; // nedir.anlambilim.net 的请求,但正在尝试从 http; // mankenresimleri.net 提供服务并返回 404;同样的情况在服务器上的其他域中也很常见且相互对应。
据我从日志中得出的结论,这种情况主要发生在 Google Bot、iPhone 和 Android 设备上。我无法在我的计算机上重现该错误,但可以从日志和 Google 网站管理员工具抓取错误报告中看到。
请帮忙。