Configuring Mono and ASP.Net on Nginx

For work I need to setup one domain with multiple subdomains. The basic idea for the website is the same as Fog Bugz, in that it’s a web hosted app. And each customer has their own site e.g. would be johhny’s site.

For the technology side we use ASP.Net Web forums for the actual software, that is is running an instance of WebForms on Mono.  But for the main site I want to run ASP.Net MVC since I like the MVC model and mono now (mostly) supports ASP.Net MVC in the current daily builds.

For the server software I’m using Nginx and the Mono FastCGI interface.  The important configuration bits are

#user  nobody;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/;

events {
    worker_connections  1024;

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] $request '
    #                  '"$status" $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost *;
	root /usr/local/nginx/html/$host;
        #charset koi8-r;

        access_log  logs/access.log;
	location / {	
		 root /usr/local/nginx/html/$host/;
	 	 index index.html index.htm index.aspx default.aspx Default.aspx;
		 fastcgi_index Default.aspx;
		 fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html/$host$fastcgi_script_name;
	 	 include ../conf/fastcgi_params;

        #location / {
        #    root   html;
	#    index index.html index.html index.aspx default.aspx Default.aspx;

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;


To run the mono fastcgi server use

fastcgi-mono-server2 /, /socket=tcp:

Doing the above results in resolving to /usr/local/nginx/html/ and resolving to /usr/local/nginx/html/ also mono will serve the two directories as two separate ASP.Net Applications.


7 thoughts on “Configuring Mono and ASP.Net on Nginx

  1. Pingback: Mono FastCGI automatic subdomain apps « A blog on math

  2. Pingback: 2010 in review « Math and More

    • I’m sorry I don’t have any specific suggestions, it’s been a while since I’ve setup Mono with MVC. The only thing I can suggest is creating a new MVC2 project in Mono that works and comparing the configuration with the existing MVC2 project that you’re converting.

  3. Hello, I just hopped over to your web site via StumbleUpon. Not somthing I might usually browse, but I enjoyed your thoughts none the less. Thanks for making something worthy of reading.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s