passing header information on to backend Apache/PHP

Gena Makhomed gmm at csdoc.com
Sun Apr 5 19:26:25 MSD 2009


On Sunday, April 5, 2009 at 16:02:34, Peter Langhans wrote:

PL> My problem is, that I need my php scripts to know
PL> in some way or another whether SSL is used or not
PL> (to include either https or http javascript files e.g.).

PL> When using nginx as webfrontend proxy, it accepts all the ssl
PL> connections and it's working fine, but when I proxy through to
PL> apache, the knowledge about SSL is 'lost'. If possible, I don't
PL> want to be using different ports for proxying through to apache.
...
PL> Does anyone have an idea how I can get any custom set header,
PL> set in the nginx.conf through to the php scripts?

nginx config:
=============

proxy_set_header X-Nginx-Scheme $scheme;

# nginx variable $scheme will be 'http' or 'https'.

apache config:
==============

SetEnvIf X-Nginx-Scheme "^https$" HTTPS=on

# Apache environment variable HTTPS will be 'on' or not defined.

PHP code:
=========

$scheme = getenv('HTTPS') && strtolower(getenv('HTTPS')) != 'off'
    ? 'https'
    : 'http';

# PHP variable $scheme will be 'http' or 'https'.

-- 
Best regards,
 Gena






More information about the nginx mailing list