Nginx Reverse SSL Proxy with PHP

This trick introduce the way of creating nginx reverse SSL proxy that works with PHP in load balancing environment.

Example network structure


1. Nginx proxy config file for ssl connection
define upsteam in nginx.conf

define the

2. Web server behind the proxy
2.1. Install pecl_http extension with pecl install pecl_http. (This extension allow you to obtain headers from cgi mode, ideally for php-fpm)

2.2. In PHP script, use

To check if the request is from https