Y
Y
Yurka Blokhin2017-04-05 08:53:52
PHP
Yurka Blokhin, 2017-04-05 08:53:52

How to add your data to $SERVER?

Tell me how to add your data to $_SERVER if the server is running on nginx?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2017-04-05
@blrik

nginx.org/ru/docs/http/ngx_http_fastcgi_module.htm...

M
Mikhail Konyukhov, 2017-04-05
@piromanlynx

1. If you are using nginx+php-fpm then fastcgi_param AAA "bbb";. It looks like: $_SERVER["AAA"] = "bbb";
2. If you are using nginx+apache then SetEnv VARNAME myvariable. It looks like: $_SERVER['VARNAME'] = 'myvariable'.
3. If you want universally, then there are 2 ways:
3.1. nginx to add a magic http header added when passing from nginx to php (x-any-magic-header). It looks like this: $_SERVER['X_HTTP_ANY_MAGIC_HEADER']. But it is necessary to clean such a header from the user's request. And yes, it's a crutch.
3.2. there is an auto_prepend_file in php (php.ini, .htaccess, poo.d/www.conf - you can cheat everywhere) and there you can directly paste what you need with the php code: $_SERVER['CCC'] = 'ddd';
Depends on what you want and the degree where you are ready to go :-)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question