MySQL and Nginx mystery

Hi all,

I have set a fastcgi upstream into Nginx configuration:

upstream fastcgi {
ip_hash;
server 192.168.0.2:9000;
server 192.168.0.3:9000;
server 192.168.0.4:9000;
}

Everything works perfect, except when I try to connect to MySQL, using
PHP.

$server = ‘192.168.0.40’;
$username = ‘tester’;
$password = ‘password’;
mysql_connect($server, $username, $password);

I get a connection error telling me that I cannot connect to MySQL using
192.168.0.2!
(or whatever server I’m on it at that specific moment)

Current setup:
3 web servers, 2 set with heartbeat, nginx as start service
2 db servers, set with heartbeat and DRBD, mysqld as start service

Is there a header that I need to set into Nginx or this is a network
configuration issue that I need to alert the host guys about?
I did set the bind-address in my.cnf to 192.168.0.40 ip.

Thanks for your help.

Posted at Nginx Forum:

What I actually try to do is: force Nginx to show one IP to the MySQL
server, no matter on what server the user is.

Posted at Nginx Forum:

On Fri, May 06, 2011 at 03:50:08PM -0400, TECK wrote:

Hi there,

What I actually try to do is: force Nginx to show one IP to the MySQL
server, no matter on what server the user is.

In your setup, nginx isn’t talking to mysql at all.

It’s the fastcgi server that runs the php code that connects to mysql.
So
you’ll want to look there for the resolution.

Good luck,

f

Francis D. [email protected]