# Getting environment variables and request headers

**URL:** <https://www.ruby-forum.com/t/getting-environment-variables-and-request-headers/162654>\
**Category:** NGINX\
**Created:** [March 12, 2009, 1:56pm UTC](https://www.ruby-forum.com/t/getting-environment-variables-and-request-headers/162654 "2009-03-12T13:56:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnSSSSl\_SSSSSetin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/50afbb/32.png) [@AnSSSSl\_SSSSSetin](https://www.ruby-forum.com/u/AnSSSSl_SSSSSetin)\
**Post date:** [March 12, 2009, 1:56pm UTC](https://www.ruby-forum.com/t/getting-environment-variables-and-request-headers/162654/1 "2009-03-12T13:56:04Z")

</div>

Hi, I am trying to get environment variables (any) and http headers, is  
there a specific way to get them in config? As an example, I need (as  
apache) %{HTTP:Authorization} , what is the corresponding variable in  
nginx for this?

---

<div class="post-metadata">

**Author:** ![AnSSSSl\_SSSSSetin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/50afbb/32.png) [@AnSSSSl\_SSSSSetin](https://www.ruby-forum.com/u/AnSSSSl_SSSSSetin)\
**Post date:** [March 12, 2009, 2:36pm UTC](https://www.ruby-forum.com/t/getting-environment-variables-and-request-headers/162654/2 "2009-03-12T14:36:38Z")

</div>

Hello!

On Thu, Mar 12, 2009 at 02:46:51PM +0200, AnÄ±l Ã‡etin wrote:

> Hi, I am trying to get environment variables (any) and http headers, is  
> there a specific way to get them in config? As an example, I need (as  
> apache) %{HTTP:Authorization} , what is the corresponding variable in  
> nginx for this?

> **[NameBright - Domain Expired](http://www.nginx-community.org/NginxHttpCoreModule#Variables)**

$http\_authorization

Maxim D.

---

<div class="post-metadata">

**Author:** ![AnSSSSl\_SSSSSetin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/50afbb/32.png) [@AnSSSSl\_SSSSSetin](https://www.ruby-forum.com/u/AnSSSSl_SSSSSetin)\
**Post date:** [March 12, 2009, 2:44pm UTC](https://www.ruby-forum.com/t/getting-environment-variables-and-request-headers/162654/3 "2009-03-12T14:44:16Z")

</div>

mod\_parsed\_vars [http://hg.mperillo.ath.cx/nginx/mod\_parsed\_vars](http://hg.mperillo.ath.cx/nginx/mod_parsed_vars) did  
this  
job. Other else modify the http access key module. 🙂

---

<div class="post-metadata">

**Author:** ![AnSSSSl\_SSSSSetin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/50afbb/32.png) [@AnSSSSl\_SSSSSetin](https://www.ruby-forum.com/u/AnSSSSl_SSSSSetin)\
**Post date:** [March 12, 2009, 4:20pm UTC](https://www.ruby-forum.com/t/getting-environment-variables-and-request-headers/162654/4 "2009-03-12T16:20:31Z")

</div>

Thanks for answers. I am confused about apache, I thought that  
%{HTTP\_USER\_AGENT} != %{HTTP:User-Agent} and so on. Also I know that  
there is a wiki and read all of them of course 🙂 Just check  
[http://www.anilcetin.com/convert-apache-htaccess-to-nginx/](http://www.anilcetin.com/convert-apache-htaccess-to-nginx/) I did this  
yesterday and now I am trying to make it more stable.

Is’nt it possible to do things like below without mod\_parsed\_vars?

if($env\_something != “1”){  
setenv something=1;  
}

??? yazmÄ±ÅŸ:
