Nginx Proxy + Apache and php5 as apache module SERVER_ADDR problem (HELP!)

Jim Ohlstein jim at ohlste.in
Mon Oct 18 00:54:31 MSD 2010


On 10/17/10 4:12 PM, DarkPepe wrote:
> Hi,
>
> First of all, my setup:
> Debian 5
> Apache 2,
> Nginx 0.6.32 as Proxy
> PHP 5 as Apache module
> All installed via apt
> And, (important data), the server handles 5 different ips wich are
> distributed among several websites, so both apache and nginx are
> listening to several ips at the same time.
>
> My problem is that php info is reporting SERVER_ADDR as 127.0.0.1, and
> Im trying to install an app wich needs to report the server's ip back to
> a central (external) server. Since it;s reporting 127.0.0.1, I cant make
> it work.
>
> I've tryed different aproaches to solve the problem but with no luck so
> far.
>
> I apreciate some help to solve this.
>
> Some of my config files:
>
> nginx.conf (relevant info)
> [code]
> http {
>      include       /etc/nginx/mime.types;
>      default_type  application/octet-stream;
>      server_names_hash_bucket_size 64;
>      log_format  main  '$remote_addr - $remote_user [$time_local]
> $request '
>                        '"$status" $body_bytes_sent "$http_referer" '
>                        '"$http_user_agent" "$http_x_forwarded_for"';
>
>      #access_log  /var/log/nginx/access.log  main;
>      sendfile        on;
>      tcp_nopush     on;
>      tcp_nodelay        on;
>      #keepalive_timeout  0;
>      keepalive_timeout  65;
>
>      gzip  on;
>      gzip_types  text/plain text/css text/javascript text/html
> application/x-javascript;
>           upstream apache {
>                     server 127.0.0.1:8888;
>                               }
>
>      # Load config files from the /etc/nginx/conf.d directory
>      include /etc/nginx/conf.d/*;
>      include /etc/nginx/sites-enabled/*;	
>
>      #
>      # The default server
>      #
>
> }[/code]
>
> virtualhost:
> [code]
>   server {
>
>      server_tokens off;
>      listen       EXTERNAL_IP_3:80;
>
>     server_name  example.com www.example.com;
>
>     location ~ \.(flv|css|js|ico|jpg|png|gif|swf|torrent)$ {
>       root /home/example/public_html/;
>       break;
>     }
>
>      location / {
>        default_type     text/html;
>
>        proxy_pass              http://apache;
>        proxy_set_header        X-Real-IP       $remote_addr;
>        proxy_set_header        Host           $host;
>        proxy_set_header        X-Forwarded-For
> $proxy_add_x_forwarded_for;
>              client_max_body_size       10m;
>              client_body_buffer_size    128k;
>              proxy_connect_timeout      120;
>              proxy_send_timeout         120;
>              proxy_read_timeout         120;
>              proxy_buffer_size          4k;
>              proxy_buffers              4 32k;
>              proxy_busy_buffers_size    64k;
>              proxy_temp_file_write_size 64k;
>
>
>      }
>    }
> [/code]
>
>
> apache virtual host:
> [code]
>
> DocumentRoot /home/example/public_html
> DirectoryIndex index.php index.htm index.html
> ServerName example.com
> ServerAlias www.example.com
> CustomLog /var/log/apache2/access_example.log combined
> ErrorLog /var/log/apache2/apacheerror_example.log
>
> Options +FollowSymLinks
> AllowOverride All
> Order deny,allow
> allow from all
> RewriteEngine On
> RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
> RewriteRule .* - [F]
>
>
> [/code]
>
>
> phpinfo() (relevant info):
> [code]
> SERVER_SOFTWARE	Apache
> SERVER_NAME	www.example.com
> SERVER_ADDR	127.0.0.1
> SERVER_PORT	80
> REMOTE_ADDR	192.168.0.2 (Client IP)
> [/code]
>
>
> Thank you guys!
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,141655,141655#msg-141655
>
>

Do you have mod_rpaf installed in your Apache?

http://stderr.net/apache/rpaf/

-- 
Jim Ohlstein



More information about the nginx mailing list