Need help with global variable

I am hosting a site that requires the following (according to the
developer)
for a script license verification"

“global variable available from the server.”

_SERVER[‘SERVER_ADDR’]

The best that I can understand is that they need the server’s IP address
to
be returned.

“SERVER_ADDR” does not seem to be recognized by Nginx. Where do I go
with
this?

Jim

you’d need to set that in a fastcgi_param

fastcgi_param SERVER_ADDR $server_addr;

is what i have. i haven’t confirmed or used it though.

I have that in there. Maybe I should add it to the site config file?

Jim

fastcgi_params can be set on the http {} level. i only have them defined
once.

var_dump($_SERVER) on the php script. see what it says.

This is the result:

array(40) { [“HOSTNAME”]=> string(0) “” [“PATH”]=> string(28)
“/usr/local/bin:/usr/bin:/bin” [“TMP”]=> string(4) “/tmp” [“TMPDIR”]=>
string(4) “/tmp” [“TEMP”]=> string(4) “/tmp” [“OSTYPE”]=> string(0) “”
[“MACHTYPE”]=> string(0) “” [“MALLOC_CHECK_”]=> string(1) “2”
[“USER”]=> string(3) “jim” [“HOME”]=> string(32)
“/path/to/my/domain/root” [“FCGI_ROLE”]=> string(9) “RESPONDER”
[“QUERY_STRING”]=> string(0) “” [“REQUEST_METHOD”]=> string(3) “GET”
[“CONTENT_TYPE”]=> string(0) “” [“CONTENT_LENGTH”]=> string(0) “”
[“SCRIPT_FILENAME”]=> string(41) “/path/to/my/domain/root/test.php”
[“SCRIPT_NAME”]=> string(9) “/test.php” [“REQUEST_URI”]=> string(9)
“/test.php” [“DOCUMENT_URI”]=> string(9) “/test.php”
[“DOCUMENT_ROOT”]=> string(32) “/path/to/my/domain/root”
[“SERVER_PROTOCOL”]=> string(8) “HTTP/1.1” [“GATEWAY_INTERFACE”]=>
string(7) “CGI/1.1” [“SERVER_SOFTWARE”]=> string(12) “nginx/0.7.19”
[“REMOTE_ADDR”]=> string(13) “my.ip.add.ress” [“REMOTE_PORT”]=>
string(4) “3719” [“SERVER_ADDR”]=> string(0) “” [“SERVER_PORT”]=>
string(2) “80” [“SERVER_NAME”]=> string(17) “mydomain.com
[“REDIRECT_STATUS”]=> string(3) “200” [“HTTP_HOST”]=> string(17)
mydomain.com” [“HTTP_USER_AGENT”]=> string(90) “Mozilla/5.0 (Windows;
U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3”
[“HTTP_ACCEPT”]=> string(63)
“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8”
[“HTTP_ACCEPT_LANGUAGE”]=> string(14) “en-us,en;q=0.5”
[“HTTP_ACCEPT_ENCODING”]=> string(12) “gzip,deflate”
[“HTTP_ACCEPT_CHARSET”]=> string(30) “ISO-8859-1,utf-8;q=0.7,*;q=0.7”
[“HTTP_KEEP_ALIVE”]=> string(3) “300” [“HTTP_CONNECTION”]=> string(10)
“keep-alive” [“HTTP_COOKIE”]=> string(36)
“PHPSESSID=qmuor210i861rct4te1qcmq1o6” [“PHP_SELF”]=> string(9)
“/test.php” [“REQUEST_TIME”]=> int(1225235084) }

So that variable returns an empty string.

Hmmm…

Jim

That didn’t work because the last two lines of nginx.conf are:

include /usr/local/nginx/conf/fastcgi_params;
include /usr/local/nginx/sites-enabled/*;

So it was reset in fastcgi_params and still returned an empty string.
What I did was hard code it in the site config. That worked. Presumably
it won’t output for other sites on the server either, not that it’s
really an issue.

Thanks for your help Mike. I appreciate it greatly!

Best,

Jim

Just a quick guess. You are doing something like this in each of your
sites
fastcgi section? setting the script filename in each site like
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/some/path/to/public_html/$fastcgi_script_name;

If you are doing this you actually reset all the http fastcgi_params
that
are set in any top level. Again if this is the case you need to either
reinclude the fastcgi_params file in each of your site or change your
SCRIPT_FILENAME to
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
in your fastcgi_params file and then in each of your server sections it
will
automatically have the script_filename set and you no longer have to do
it
for each server.

On Tue, Oct 28, 2008 at 7:11 PM, Rob S. [email protected]
wrote:

If you are doing this you actually reset all the http fastcgi_params that
are set in any top level. Again if this is the case you need to either
reinclude the fastcgi_params file in each of your site or change your
SCRIPT_FILENAME to
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
in your fastcgi_params file and then in each of your server sections it will
automatically have the script_filename set and you no longer have to do it
for each server.

exactly. i set it once on a global level and i don’t need to bother.
the only specific line is “fastcgi_pass” everything else including
fastcgi_index is inherited

SERVER_ADDR is defined but empty. i am not sure here what to say…

you -could- hard-code it in the nginx config probably…