# Getting ip address from fastcgi for Wordpress plugin

**URL:** <https://www.ruby-forum.com/t/getting-ip-address-from-fastcgi-for-wordpress-plugin/205082>\
**Category:** NGINX\
**Created:** [March 29, 2011, 4:22am UTC](https://www.ruby-forum.com/t/getting-ip-address-from-fastcgi-for-wordpress-plugin/205082 "2011-03-29T04:22:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 29, 2011, 4:22am UTC](https://www.ruby-forum.com/t/getting-ip-address-from-fastcgi-for-wordpress-plugin/205082/1 "2011-03-29T04:22:21Z")

</div>

I am running a Redhat EL5 server using Nginx 0.8.54 on the frontend,  
with Apache 2.2.3 on the backend and mod\_rpaf to forward the IP address  
to be used in filtering spam from Wordpress comments using the Spam Free  
Wordpress plugin. ([http://www.toddlahman.com/spam-free-wordpress/](http://www.toddlahman.com/spam-free-wordpress/))

I would like to use fastcgi to serve PHP, but I am not aware of any way  
for fastcgi to forward the visitor’s IP address like mod\_rpaf does for  
Apache for use by my Wordpress plugin.

I don’t currently use mod\_fastcgi to connect to an external fastcgi  
process like spawn-fcgi because I can’t get it to work, or php-fpm  
because I cannot find the proper php-common rpm and other dependency rpm  
files I need to connect memcached and other stuff.

Does anyone have a solution to this? If so could you share your complete  
configuration files from Nginx, and Apache, or the fastcgi configuration  
outside either of these applications? I am open to any and all  
suggestions, but appreciate complete config examples to save time.

Thank you.

Posted at Nginx Forum:

> **[getting ip address from fastcgi for Wordpress plugin](https://forum.nginx.org/read.php?2,186497,186497#msg-186497)**
>
> I am running a Redhat EL5 server using Nginx 0.8.54 on the frontend, with Apache 2.2.3 on the backend and mod\_rpaf to forward the IP address to be used in filtering spam from Wordpress comments using the Spam Free Wordpress plugin....

---

<div class="post-metadata">

**Author:** ![toddlahman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a698b9/32.png) [@toddlahman](https://www.ruby-forum.com/u/toddlahman)\
**Post date:** [March 29, 2011, 10:45am UTC](https://www.ruby-forum.com/t/getting-ip-address-from-fastcgi-for-wordpress-plugin/205082/2 "2011-03-29T10:45:46Z")

</div>

Hello!

On Mon, Mar 28, 2011 at 10:21:31PM -0400, toddlahman wrote:

> I am running a Redhat EL5 server using Nginx 0.8.54 on the frontend,  
> with Apache 2.2.3 on the backend and mod\_rpaf to forward the IP address  
> to be used in filtering spam from Wordpress comments using the Spam Free  
> Wordpress plugin. ([http://www.toddlahman.com/spam-free-wordpress/](http://www.toddlahman.com/spam-free-wordpress/))
> 
> I would like to use fastcgi to serve PHP, but I am not aware of any way  
> for fastcgi to forward the visitor’s IP address like mod\_rpaf does for  
> Apache for use by my Wordpress plugin.

In fastcgi visitor’s ip address is always passed to application  
with appropriate fastcgi params. Bundled fastcgi\_params file have  
them properly set:

fastcgi\_param REMOTE\_ADDR $remote\_addr;  
fastcgi\_param REMOTE\_PORT $remote\_port;

Maxim D.

---

<div class="post-metadata">

**Author:** ![toddlahman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a698b9/32.png) [@toddlahman](https://www.ruby-forum.com/u/toddlahman)\
**Post date:** [March 29, 2011, 1:04pm UTC](https://www.ruby-forum.com/t/getting-ip-address-from-fastcgi-for-wordpress-plugin/205082/3 "2011-03-29T13:04:47Z")

</div>

With my current configuration below the IP address is not appearing  
properly in Wordpress.

In the fastcgi.conf I have:

fastcgi\_param REMOTE\_ADDR $remote\_addr;

In the nginx.conf I have:

upstream php {  
server 127.0.0.1:9000;  
}

location ~ .php$ {  
fastcgi\_split\_path\_info ^(.+.php)(/.+)$;  
include fastcgi.conf;  
fastcgi\_intercept\_errors off;  
fastcgi\_pass php;  
}

cgi.fix\_pathinfo = 0; in php.ini

With this I got a blank page when submitting a comment.

I tried adding

```
    fastcgi_pass_header Host;
    fastcgi_pass_header X-Real-IP;
    fastcgi_pass_header X-Forwarded-For;

```

Now I get 502 Bad Gateway (Nginx).

What am I missing?

Posted at Nginx Forum:

> **[Re: getting ip address from fastcgi for Wordpress plugin](https://forum.nginx.org/read.php?2,186497,186583#msg-186583)**
>
> I am running a Redhat EL5 server using Nginx 0.8.54 on the frontend, with Apache 2.2.3 on the backend and mod\_rpaf to forward the IP address to be used in filtering spam from Wordpress comments using the Spam Free Wordpress plugin....

---

<div class="post-metadata">

**Author:** ![toddlahman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a698b9/32.png) [@toddlahman](https://www.ruby-forum.com/u/toddlahman)\
**Post date:** [March 30, 2011, 10:21am UTC](https://www.ruby-forum.com/t/getting-ip-address-from-fastcgi-for-wordpress-plugin/205082/4 "2011-03-30T10:21:17Z")

</div>

Was able to get php-fpm installed on the server from the remi repo.  
Everything works fine now with the same configuration above.

> **[PHP-FPM and NGINX - Remi's RPM repository - Blog](https://blog.remirepo.net/post/2010/09/27/PHP-FPM-and-NGINX)**
>
> Since PHP 5.3.3, the PHP-FPM engine is bundled. The php-fpm package is available in remi repository and will be soon in rawhide. This entry show how to use it with the nginx web

Posted at Nginx Forum:

> **[Re: getting ip address from fastcgi for Wordpress plugin](https://forum.nginx.org/read.php?2,186497,186824#msg-186824)**
>
> I am running a Redhat EL5 server using Nginx 0.8.54 on the frontend, with Apache 2.2.3 on the backend and mod\_rpaf to forward the IP address to be used in filtering spam from Wordpress comments using the Spam Free Wordpress plugin....

---

<div class="post-metadata">

**Author:** ![toddlahman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a698b9/32.png) [@toddlahman](https://www.ruby-forum.com/u/toddlahman)\
**Post date:** [March 29, 2011, 1:14pm UTC](https://www.ruby-forum.com/t/getting-ip-address-from-fastcgi-for-wordpress-plugin/205082/5 "2011-03-29T13:14:40Z")

</div>

I failed to see the php-cgi process wasn’t running when I sent the last  
message. I am still getting a blank page, not 502 bad gateway.

Posted at Nginx Forum:

> **[Re: getting ip address from fastcgi for Wordpress plugin](https://forum.nginx.org/read.php?2,186497,186584#msg-186584)**
>
> I am running a Redhat EL5 server using Nginx 0.8.54 on the frontend, with Apache 2.2.3 on the backend and mod\_rpaf to forward the IP address to be used in filtering spam from Wordpress comments using the Spam Free Wordpress plugin....
