3

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.

Rui Marques
  • 190
  • 13

1 Answers1

2

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.

CloudWeavers
  • 2,511
  • 1
  • 14
  • 17
  • Doesn't this solution create some overhead on a single server? Can you supply a detailed how-to? – Rui Marques Jan 03 '12 at 14:07
  • Actually, using 2 instances of NGINX would create some overhead. However, re-reading the questions and my answer, I don't see why it would be required to add a second layer of NGINX. The NGINX already act as a load balancer, you simply need to forward to different pool of fastcgi-mono-server ... (run one for each website). They won't be able to use any shared memory, but this isn't as bad as having to kill all site. – CloudWeavers Jan 03 '12 at 14:15
  • The idea is to mimic the same isolation we have on IIS using application pools. I don't wan't to kill all sites, just to be able to have control over each on individually. To you have some configuration examples? – Rui Marques Jan 03 '12 at 14:24
  • I really want to give you this +50. – Rui Marques Jan 05 '12 at 21:57
  • 1
    Gave another shot with more precise solution and included a reference and examples. Sorry for the delay ;-) – CloudWeavers Jan 09 '12 at 13:38
  • Tks. I'll give it a try. – Rui Marques Jan 09 '12 at 17:53
  • Did it worked as you wanted? – CloudWeavers Jan 12 '12 at 14:23
  • I'm going to test it very soon with a new server. I'll share the results. Thanks again. – Rui Marques Jan 13 '12 at 09:08
  • There is no longer a bounty on the post. Is this why you waited before giving the points ? – CloudWeavers Jan 16 '12 at 21:03
  • No. I did not know of so short time limit. When I've set the bounty I've lost the 50 points. – Rui Marques Jan 17 '12 at 17:27