Nginx运行Mono Web (ASP.NET)

Mono Web除了可使用Apache/mod_mono方式承载运行外,还可使用Nginx/FastCGI方式运行。php

Nginx配置asp.net更简单方便,用处也多,能够经过FastCGI运行asp.net, php等,经过反向代理作负载均衡,也可运行python web.html

以Ubuntu为例python

配置nginx (/etc/nginx/sites-available/default),让站点根目录以FastCGI方式运行nginx

server {
    listen 80;
    root /usr/share/nginx/www;
    index index.html index.htm;

    server_name localhost;
    access_log /var/log/nginx/chat.log;

    location / {
        root /var/www/chat;
        index default.aspx default.html;
        fastcgi_index Default.aspx;
        fastcgi_pass 127.0.0.1:8099;
        include /etc/nginx/fastcgi_params;
    }
}

编辑/etc/nginx/fastcgi_paramsweb

fastcgi_param    PATH_INFO        "";                        
fastcgi_param    SCRIPT_FILENAME        $document_root$fastcgi_script_name;

安装fastcgi-mono-server4模块app

apt-get install fastcgi-mono-server4

运行FastCGI Mono负载均衡

fastcgi-mono-server4 /applications=/:/var/www/chat/ /socket=tcp:127.0.0.1:8099
# just via domain visit
fastcgi-mono-server4 /applications=www.domain.com:/:/var/www/chat/ /socket=tcp:127.0.0.1:8099

 

注:applications={URL访问地址Path}:{物理路径},与上面的nginx config一致,URL访问地址可使用域名。如此地址配置错误,会报异常"No Application Found"匹配不到asp.net

 

关于Nginx的URL Rewrite,参考,规则也能够放到一个单独的文件dom

相关文章
相关标签/搜索