Nginx and Coldfusion - Using Nginx as a reverse proxy for more performance
The usual setup is ColdFusion on either Windows with IIS or on Linux with Apache.
Both webservers are great webservers unless you get excessive load on them. At that time you wish that you had one server to do all the static files and one or more servers to do the ColdFusion requests.
Enter Nginx, the lightweight webserver written by Igor Sysoev. Nginx is one of the fastest webservers around and due to its different architecture will yawn at the load while Apache is already collapsing.
I just want to post my two config files to show how Nginx can be configured to work as a reverse proxy.
The main nginx.conf file:
This is pretty much the default config file except for the
And here a config file from the sites-enabled folder:
This is it. With this config every request to the domain some.domain.com will serve .gif, .js, .ico and .txt files from the local Nginx cache which will refresh after one day (1d). All .cfm files will be passed to the ColdFusion server. Every other file type (e.g. .jpg, .php) will result in a 404 that will never even reach the ColdFusion server. And this config could be enhanced to have n-ColdFusion servers handle the requests. By using this you can leave your current CF servers as they are and store the static files on them as you do now. Nginx will contact your CF server for each static file only once a day.
Of course this config could be used for ASP, PHP or any other application server as well, just change the .cfm to whatever you like.
If you've read this far you might as well follow me on Twitter here.