ASP.Net MVC 2 on nginx/mono 2.8

纵然是瞬间 提交于 2019-12-03 03:19:09

Does your application work with xsp (xsp4 if you are using .net 4.0)? You'll want to make sure that is working before you try configuring the connection to another web server.

Does nginx know where to find mono? You most likely have a parallel install and it won't be in the default paths.

I use apache, but you may still find some of the instructions on my blog useful: http://tqcblog.com/2010/04/02/ubuntu-subversion-teamcity-mono-2-6-and-asp-net-mvc/

Jean

I've been doing some testing with this as well, using all ubuntu10.10 binaries. From what I can make from it, either nginx fails to pass the hostname of the mono server fails to receive it over the fastcgi protocol. Anyhow, the tutorial line:

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

doesn't work. Removing the hostname makes the thing work:

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

but this of course blocks the use of multiple virtual mono hosts.

Since you are running ASP.NET MVC 2 application you should use fastcgi-mono-server4.

Adding following line in /etc/nginx/fastcgi_param resolves the issue for me. It also allows to use multiple virtual hosts.

fastcgi_param HTTP_HOST $host;

I had this problem just now, I too had been following the document on the mono site:

I was trying to start the fastcgi-mono-server as it suggested:

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

However when I did it like that I got the same problem as you. I changed it to this:

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

And it worked ( I had to type in www.domain1.xyz/Home/Index to see my MVC page, not worked out how to stop it looking for www.domain1.xyz/default.aspx yet XD ).

You need to make sure the domain set in your site config matches the domain passed to the fastcgi server. So for example if your default site (/etc/nginx/sites-enabled/default) has the following config:

server {
    ...
    server_name www.domain1.xyz;
    ...
}

You would need to pass that domain into the fastcgi server:

sudo fastcgi-mono-server4 /applications=www.domain1.xyz:/:/var/www/www.domain1.xyz/ ...

Then when you access the site it will obviously need to be with that domain you set.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!