Forum: NGINX Problem in $remote_addr when proxying

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
71ac28da4aa400cdc357abad1027ff8b?d=identicon&s=25 Tyler Durden (Guest)
on 2009-05-18 16:14
(Received via mailing list)
Hi,
I have nginx as frontend for serving static files and a proxy to
apache for dinamic request.
The problem is on the $remote_addr that arrive to apache as 127.0.0.1

In my virtualhost:

upstream my_webcluster {
    server 127.0.0.1:8080;
}

server {
    ...
    location  / {
        proxy_pass  http://my_webcluster;
        include     /etc/nginx/proxy.conf;
    }
    ...
}


in /etc/nginx/proxy.conf:

proxy_redirect              off;
proxy_set_header            Host              $http_host;
proxy_set_header            X-Real-IP         $remote_addr;
proxy_set_header            X-Forwarded-For
$proxy_add_x_forwarded_for;
client_max_body_size        10m;
client_body_buffer_size     128k;
proxy_connect_timeout       90;
proxy_send_timeout          90;
proxy_read_timeout          90;
proxy_buffer_size           4k;
proxy_buffers               4 32k;
proxy_busy_buffers_size     64k;
proxy_temp_file_write_size  64k;

What I'm doing wrong here?

Thanks in advance,
Tyler
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-05-20 14:21
(Received via mailing list)
On Mon, May 18, 2009 at 03:06:00PM +0100, Tyler Durden wrote:

>
> in /etc/nginx/proxy.conf:
> proxy_read_timeout          90;
> proxy_buffer_size           4k;
> proxy_buffers               4 32k;
> proxy_busy_buffers_size     64k;
> proxy_temp_file_write_size  64k;
>
> What I'm doing wrong here?

You need to install mod_rpaf on Apache side:
http://stderr.net/apache/rpaf/
5543e37c90a58f3eb477bf37a2134dc4?d=identicon&s=25 lejeczek (Guest)
on 2009-06-12 13:29
(Received via mailing list)
hello there, I'm having similar(more newbie) problem with simple php,
it gives local fcgi address in return instead of user agent's, where to
look?
cheers
5543e37c90a58f3eb477bf37a2134dc4?d=identicon&s=25 lejeczek (Guest)
on 2009-06-12 13:44
(Received via mailing list)
sorry, pasting:

server {
  listen        10.0.0.100;
  server_name   .php.local;

  location / {
    if ($request_method = POST) {
      proxy_pass        http://127.0.0.1:8001;
    }
    set $memcached_key  "phpLocal:$uri";
    memcached_pass      127.0.0.1:11211;
    default_type        "text/html";
    error_page          404 502 @fallback;
  }

  location @fallback {
    proxy_pass      http://127.0.0.1:8001;
  }

  location ~*
^.+\.(flv|html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
    root /usr/share/nginx/php.local;
    expires 39d;
    break;
  }
}

server {
  listen        127.0.0.1:8001;
  server_name   .php.local;

  root          /usr/share/nginx/php.local;
  index         index.htm index.php;
  autoindex   on;

  location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME
/usr/share/nginx/php.local$fastcgi_script_name;
    include        fastcgi_params;
 }
}
This topic is locked and can not be replied to.