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

相關文章
相關標籤/搜索