Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

nginx proxy server serving from wrong document root

$
0
0
I have a Double Quad-Core Centos 6.3 server with 32GB ram.

I have installed nginx for serving static files and as reverse proxy server to apache as the backend. The panel I am using is IspConfig 3.0.5.2.

Everything seemed to have been working fine at the beginning, but recently I have realized that there is something wrong! Nginx is serving from wrong document root. I have crawled across google and nginx fora but I could not find a solution. I have made several modifications / alterations / amendments to the config files and tried to debug thorugh nginx logs but all for no joy!

Below are my config files and excerpts from logs. Please help me sort out.

//FILE /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
// FILE /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

Here is an excerpt from the log file with my custom format "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 (compatib le; Googlebot/2.1; +http://www.google.com/bot.html)" "-"

/ne_demek/hatil is a request to http://nedir.anlambilim.net, but it is being tried to be served from http;//mankenresimleri.net and returns 404; Same situation is common and reciprocal among other domains on the server.

This mostly happens to Google Bot, iPhone and Android devices as far as i can conclude from logs. I could not reproduce the error on my machine, it is visible from the logs and Google Webmaster Tools Crawl Error Reports.

Please help.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>