-
Notifications
You must be signed in to change notification settings - Fork 48
Nginx configuration
HyperFastCgi has keepalive
command line option with default value of true
. This option instructs HyperFastCgi to try to reuse connections with Nginx. This increases performance, especially with lots of small requests. That is because Nginx does not need to close a connection to HyperFastCgi in order to successfully process a request. Also Nginx reuses the connection when processing another request. In order for this to work though Nginx should be configured appropriately.
Below is a sample configuration with minimal number of open connections between Nginx and HyperFastCgi set to 32. This configuration uses a unix socket, but with the commented out line you can switch to a tcp socket.
upstream fastcgi_backend {
server unix:/tmp/my-web-app.socket;
#server 127.0.0.1:9000;
keepalive 32;
}
server {
listen 80;
server_name my-web-app;
access_log /var/log/nginx/my-web-app.log;
location / {
root /path-to-my-web-app-web-config-folder/;
index index.html index.htm default.aspx Default.aspx;
fastcgi_index Default.aspx;
fastcgi_keep_conn on;
fastcgi_pass fastcgi_backend;
include /etc/nginx/fastcgi_params;
}
}
If, for some reason, you do not want to reuse connections between Nginx and HyperFastCgi use the following Nginx configuration. Again - it uses unix sockets and you can use the commented out line to switch to tcp sockets. Also do not forget to run HyperFastCgi with /keepalive=false
.
server {
listen 80;
server_name my-web-app;
access_log /var/log/nginx/my-web-app.log;
location / {
root /path-to-my-web-app-web-config-folder/;
index index.html index.htm default.aspx Default.aspx;
fastcgi_index Default.aspx;
fastcgi_pass unix:/tmp/my-web-app.socket;
#fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/fastcgi_params;
}
}
Cvetomir Todorov