4

I'm trying to get server work in the way nginx->apache2.4->php-fpm(via mod_proxy_fcgid) (nginx for serving static files) (I'm not sure apache is even needed now). It works but I got few questions.

When I used apache2.2 with php as apache module (on old server) I could set php_admin_value like for each virtual host for example php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f owner@example.com". Now when I'm using php-fpm apache doesn't understand those and won't start. How can I set these values for each virtual host while using php-fpm?

Second question is, how do I make _SERVER["REMOTE_ADDR"] filled with real remote address? With nginx+apache+php as apache module it was solved with mod rpaf, but as of now _SERVER["REMOTE_ADDR"] displays 127.0.0.1.

Last question. If I decide to just go nginx+php-fpm what "essential" functionality I will lose by discarding apache?

UPDATE 1.
Apparently mod_rpaf wasn't doing what it was supposed to do. Apache actually provides official mod with similar functionality for 2.4. In case someone will need it too, here is how you get it:
1. wget https://svn.apache.org/repos/asf/httpd/httpd/trunk/modules/metadata/mod_remoteip.c
2. apxs -cia mod_remoteip.c
3. Enable mod LoadModule remoteip_module usr/lib/apache2/modules/mod_remoteip.so
4. Configure mod

<IfModule remoteip_module>
RemoteIPHeader X-Real-IP
RemoteIPInternalProxy 127.0.0.1
</IfModule>

Note: Step 4 Depends on your nginx setup. I assume it would work with X-Forwarded-To too. With this, problem #2 is solved.

UPDATE 2.
These options can be set in pools' configuration files as php_admin_value[open_basedir] for example. This requires separate pool for each virtual host which is IMO not that great but since I only have 4 virtual hosts it doesn't get too messy.
And so, problem #1 is solved.

Igor Yavych
  • 195
  • 2
  • 11

2 Answers2

4

This can be set with:

fastcgi_param PHP_VALUE 'sendmail_path "/usr/sbin/sendmail -t -i -f owner@example.com"';

If you have multiple values to pass, they must all be in the same PHP_VALUE, separated by \n.

fastcgi_param PHP_VALUE 'allow_url_fopen 0\nmemory_limit 64M'
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • It's nginx directive, right? It didn't have any effect. If it's apache directive, apache didn't start due to invalid command. – Igor Yavych Dec 15 '13 at 20:28
0
  1. Add remote IP to HTTP headers (X-Forwarded-For) for apache by adding following to nginx:

    proxy_set_header X-Forwarded-For $remote_addr;

  2. Use mod_extract_forwarded apache module to extract these IP's

GioMac
  • 4,444
  • 3
  • 24
  • 41