Nginx – How to add a new website to a fastcgi-mono-server4 process on nginx without having to restart existing websites

asp.netfastcgimononginx

I know this might be related but I have a script that loads fastcgi-mono-server for defined websites on a configuration file and I need to a new website to the pool without having to reload all fastcgi process.

Doing

nginx -s reload

Just reload each server (website) configuration and I need a smoother process to add a new asp.net website to the current worker process.

Best Answer

The 'only' way would be to:

  • isolate all fast-cgi processes
  • forward connections to them with NGINX.

NGINX can forward connections toward a pool of fastCGI mono server. You can execute different fastcgi process for each of the website/application and modify you NGINX configuration to point to each of the application depending on the vhost or URL. Adding new sites will only requires a NGINX reload - which will NOT reload the whole mono server, only the NGINX internal forwarding rules.

Additional configuration examples can be found there: http://www.mono-project.com/FastCGI_Nginx

For reference sake, I'm posting the main part: Nginx configuration (as of version 0.7.63) is located in /etc/nginx/nginx.conf (which contains http configuration) and in /etc/nginx/sites-available/default (where is configuration of particular virtual host or hosts). In order to setup ASP.NET or ASP.NET MVC web application, you need to modify virtual host configuration.

NGINX vhost configuration bloc. This forward to a fastcgi process running on port 9000 of the same system. You could be using 9001 for the second apps, etc. You could also be using dedicated servers to run your application, in such case, NGINX becomes a pseudo HTTP load balancer.

server {
     listen   80;
     server_name  www.domain1.xyz;
     access_log   /var/log/nginx/your.domain1.xyz.access.log;

     location / {
             root /var/www/www.domain1.xyz/;
             index index.html index.htm default.aspx Default.aspx;
             fastcgi_index Default.aspx;
             fastcgi_pass 127.0.0.1:9000;
             include /etc/nginx/fastcgi_params;
     }
}

and you control individual mono 'application' with:

fastcgi-mono-server2 /applications=www.domain1.xyz:/:/var/www/www.domain1.xyz/ /socket=tcp:127.0.0.1:9000

Note: Answer edited a few times to provide additional and a more precise solution.