I currently run several instances of BlogEngine.NET, a .NET-based blogging tool, under Mono with nginx in front of it. The config rules I'm currently using are below...
[code]
index default.aspx;
location ~ \.(aspx|asmx|ashx|asax|ascx|soap|rem|axd|cs|config|dll)$ {
fastcgi_index default.aspx;
include /etc/nginx/fastcgi_params_mono;
}
[/code]
This allows nginx to serve images, while passing the .NET-allocated extensions to the Mono FastCGI server. However, I'm having a problem with the way images are handled. When they're uploaded as part of BlogEngine, they are written to the App_Data folder, but the href that's created looks like "image.axd?image=encoded/path/to/image.png". This means that the location matched above is actually .png, and it tries to load it off the file system.
There are other shortfalls of these rules as well. In an MVC environment, for example, where the URLs don't end with these extensions, nginx will try to serve the file. However, I don't want to just send everything to the Mono FastCGI server, because in my testing, it seemed to not render straight images reliably. So, what I'm looking for is a reverse of the rule above - something where I can enumerate the image extensions I'm expecting (.gif, .jpg, .png) and have nginx serve them, and pass everything else to Mono.
I'm thinking it would look something like...
[code]
location /the/actual/site {
location ~ \.(gif|jpg|png)$ {
try_files $url @monolabel;
}
}
location @monolabel {
index default.aspx;
include /etc/nginx/fastcgi_params_mono;
}
[/code]
Does that look right? Is my thought process above correct? My goal is to have nginx serve images, and everything else be passed to Mono.
Thanks. :)
Edited 1 time(s). Last edit at 01/16/2011 11:15PM by daniel_summers.