Send additional HTTP headers to Nginx’s FastCGI

It’s not that often that I come across a useful, but undocumented feature in a major software application.  It happened recently, so I’ll document it here just for the future self.

For a particular setup, I had to send additional HTTP headers (let’s use X-GEOIP for this example) to the PHP-FPM, which was configured as a FastCGI backend in Nginx web server.  This StackOverflow thread suggested several solutions, but this one was the easiest and worked like a charm: use Nginx’s fastcgi_param directive AND prefix your variables with HTTP_.  For example:

location ~ \.php$ {
  fastcgi_param HTTP_X_GEOIP $geoip;
  ... other settings
}

 

F5 acquires NGINX

NGINX, the company behind one of the most popular web servers, has been acquired by F5. Of course, I’m glad for the NGINX team and founders, for who this is quite an accomplishment. But at the same time, much like many of the recent acquisitions, this one worries me. NGINX and F5 were competing in certain areas. That competition is now gone.

As always, they say that they will keep NGINX brand, team, technology, and even invest more in the Open Source side of things. But I’m not holding my breath. We’ve seen way too many screw ups on that front in the last few years.

Having the Open Source offering is good though. If it continues to grow and develop – even better. But if not, at least there is an option of forking, rebranding, and building on top.

HTTP/2 Server Push with PHP


A few days ago I blogged about the exciting news from the Nginx about the support for HTTP/2 Server Push.  It’s good to see that this is getting picked up pretty fast.  Here are a couple of examples:

Mainstream support and implementation alternatives are not too far away, and that’s super exciting.




Nginx 1.13.9 and HTTP/2 Server Push


Here are some very exciting news from the Nginx front lines: HTTP/2 Server Push is now available in the latest and greatest Nginx 1.13.9, which was released yesterday!

Server Push was one of the most exciting features for me in all of the HTTP/2 specification.  But I wasn’t quite sure how it will be implemented, and, most importantly, how it can be made easily available to the web developers, who are often few levels removed from the web server configuration.  I think Nginx solves the problem quite elegantly.

On the configuration level, “location” directives are often available to the web developers withing the virtual host / server.  But for those who can’t use those or don’t want to mess around with the configuration files, an even easier option is available – Link HTTP header.

I’m sure this will soon be widely supported in all the major libraries and frameworks, much like HTTP cookies are.   Great times ahead!