Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides

FAQ
It is currently Fri Dec 01, 2023 12:55 am


This forum is dedicated to Apache, Nginx, Lighttpd, Squid and other HTTP transport protocol related software

Author Message
designeru
  Post  Post subject: Nginx + apache (for PHP) with real IP addresses in logs  |  Posted: Tue May 18, 2010 9:49 am

Joined: Thu Dec 31, 2009 4:44 pm
Posts: 10

Offline
 

Nginx + apache (for PHP) with real IP addresses in logs

I was trying to get nginx to work with apache 2.2.15. The idea is that nginx will ofer the static content and apache the PHP content.
Very easy to do and a lot of documentation is available over the internet on how to do it. However, i encountered some issue when i was trying to get nginx to send the real IP address of the visitor to the apache server and not the localhost ip (127.0.0.1).

The solution came with the mod_rpaf module for apache. You can download it from here. In case that website will go down for some reasons, i've attached to this post the latest available version of this module (released 01-Jan-2008 22:42 - that's more than 2 years ago).

Here is how my configuration looks like:

1. Apache2 conf (related with mod_rpaf, the rest you can google for help)
Code:
LoadModule rpaf_module modules/mod_rpaf-2.0.so
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1 10.255.254.1
RPAFheader X-Forwarded-For

Note: I have both 127.0.0.1 and 10.255.254.1 ips configured as local IP. Most probably you will have only 127.0.0.1...

2. nginx conf (related with proxy redirection to apache2)
Code:
in the server section
            location ~ \.php$ {
                    proxy_pass http://127.0.0.1:82;
            }

in the http section
                    proxy_redirect            off;
                    proxy_connect_timeout     60;
                    proxy_send_timeout        60;
                    proxy_read_timeout        60;
                    proxy_ignore_client_abort off;
                    proxy_intercept_errors    on;
                    proxy_ignore_headers   Expires Cache-Control;
                    proxy_set_header        Host            $host;
                    proxy_set_header        X-Real-IP       $remote_addr;
                    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;


Attachments:
File comment: mod_rpaf-0.6.tar - please download the sources from the oficial site. This is a very old version.
mod_rpaf-0.6.tar.gz [7.51 KiB]
Downloaded 960 times



Top
Display posts from previous:  Sort by  
E-mail friendPrint view

Topics related to - "Nginx + apache (for PHP) with real IP addresses in logs"
 Topics   Author   Replies   Views   Last post 
There are no new unread posts for this topic. Converting PhpBB-SEO Apache RewriteRule to Nginx rewrite

debuser

0

10583

Tue Feb 23, 2010 5:00 am

debuser View the latest post

There are no new unread posts for this topic. Apache to Nginx Server parameters translation with php function

debuser

0

105101

Thu Aug 26, 2010 7:47 am

debuser View the latest post

There are no new unread posts for this topic. Apache: how to list virtual hosts that are currently configured on my Apache server ?

LaR3

0

4772

Sun Feb 07, 2010 10:04 am

LaR3 View the latest post

There are no new unread posts for this topic. Apache 2.2 installation of mod_rewrite module without recompiling whole apache

debuser

0

6353

Tue Mar 23, 2010 11:22 am

debuser View the latest post

There are no new unread posts for this topic. NGINX: how to set the default virtual host

mandrei99

0

3985

Thu Dec 12, 2013 6:01 am

mandrei99 View the latest post

There are no new unread posts for this topic. Nginx: How to list virtual hosts

mandrei99

0

13329

Mon Feb 23, 2015 5:05 pm

mandrei99 View the latest post

There are no new unread posts for this topic. NGINX: 413 Request Entity Too Large

admin

0

2032

Thu Sep 14, 2017 4:48 am

admin View the latest post

There are no new unread posts for this topic. Nginx + php-fpm increase upload_max_filesize and other php values per vhost

mandrei99

0

8226

Mon Jan 02, 2012 9:04 am

mandrei99 View the latest post

There are no new unread posts for this topic. NGINX: How to redirect http to https website

mandrei99

0

3903

Mon Feb 09, 2015 3:27 pm

mandrei99 View the latest post

There are no new unread posts for this topic. How can I see what modules are loaded on my custom built Apache binary

LaR3

0

3083

Sun Feb 07, 2010 9:54 am

LaR3 View the latest post

 

Who is online
Users browsing this forum: No registered users and 0 guests
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
cronNews News Site map Site map SitemapIndex SitemapIndex RSS Feed RSS Feed Channel list Channel list


Delete all board cookies | The team | All times are UTC - 5 hours [ DST ]



phpBB SEO