Review the following nginx configuration:

index index.php index.html index.htm;

location ~ \.(php|phar)(/.*)?$ {
    fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$;

    fastcgi_intercept_errors on;
    fastcgi_index  index.php;
    include        fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_param  PATH_INFO $fastcgi_path_info;
    fastcgi_pass   php-fpm;

    # following lines are the magic
    set $param_https 'off';
    if ($http_x_forwarded_proto = 'https') {
      set $param_https 'on';
    }
    fastcgi_param  SERVER_PORT        443;
    fastcgi_param  SERVER_NAME        $host;
    fastcgi_param  HTTPS              $param_https;
}