Regarding setting ENV variable

Hi Friends
I want to set a env variable on nginx with perl whenever
i am accessing site with https only. can anyone help how i can do this.
I looked at post env variable in nginx.conf file it didnt help me.Is
there any way that i can set environment variable using mod_perl.

thanks

Posted at Nginx Forum:

On 3/7/12, shivnamha [email protected] wrote:

Hi Friends
I want to set a env variable on nginx with perl whenever
i am accessing site with https only. can anyone help how i can do this.
I looked at post env variable in nginx.conf file it didnt help me.Is
there any way that i can set environment variable using mod_perl.

Are you sure that’s what you need? You can pass $https with
fastcgi_param or access it with perl’s variable method:
$r->variable(‘https’) and set $ENV{…} accordingly.

Hi Alexandr
Thanks Alexander.But I didnt get u completly. I tried
by adding a ‘fastcgi_param HTTPS on;’ but this variable is getting
set for http request as well for https request. But i need to set for
https request. Can u please elaborate ur statement so that i can easily
understand it.

Posted at Nginx Forum:

thanks allot Valentin and Alexandr . It really helpful for me…

Posted at Nginx Forum:

On Thursday 08 March 2012 10:07:35 shivnamha wrote:

Hi Alexandr
Thanks Alexander.But I didnt get u completly. I tried
by adding a ‘fastcgi_param HTTPS on;’ but this variable is getting
set for http request as well for https request. But i need to set for
https request. Can u please elaborate ur statement so that i can easily
understand it.

http://nginx.org/en/docs/http/ngx_http_core_module.html#variables

fastcgi_param HTTPS $https if_not_empty; # for NGINX >= 1.1.11

For NGINX < 1.1.11:

map $scheme $https_on {
    default  '';
    https    on;
}

fastcgi_param HTTPS $https_on;

http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_param
http://wiki.nginx.org/HttpMapModule

wbr, Valentin V. Bartenev