Hello,
I have a machine 1 with nginx as a proxy before apache, and machine2
with nginx as a proxy before apache. I am moving websites from machine1
to machine2. Because DNS still points to machine1, I need to pass
traffic from machone1 to machine2 for a while.
Everything is working fine, but in machine2 nginx log I have IP of
machine1 as clients address. This is a problem because of awstats.
Can please anybody advise me that I have wrong in my configuration?
Thanks,
Martin
My machine1 configuration:
server {
listen machine1ip:80;
server_name list-of-moved-websites;
location / {
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 30s;
proxy_pass http://machine2:80;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
}
}
Machine2 configuration:
log_format main ‘$remote_addr - $remote_user [$time_local] “$request”
$status $bytes_sent “$http_referer” “$http_user_agent” “$gzip_ratio”’;
server {
listen 80;
server_name website;
access_log /var/log/nginx/website/access-website.log main;
error_log /var/log/nginx/website/error-website.log;
#default proxy settings shared are among all virtual hosts
location / {
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_connect_timeout 30s;
proxy_pass http://machine2:81; #apache
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
}
location ~*
^.+.(jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|html?|txt|tar|mid|midi|wav|bmp|rtf|js|swf|avi|mp3)$
{
#forcing browser to cache locally static content for 30 days
expires 30d;
root /var/www/squashe.cz/web/www/htdocs;
#graceful fallback in case if static content doesn't exist
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
if (!-f $request_filename) {
break;
proxy_pass http://machine2ip:81;
}
}
}