nginx坏网关502与mono fastcgi

时间:2012-08-19 07:58:07

标签: asp.net razor mono nginx fastcgi

你好,所以我一直试图让我的网站在单声道上运行(在ubuntu服务器上),我已经跟着these tutorials几乎到了这封信:

但是当我的目录不是空白时,fastcgi日志会显示:

    Notice  Beginning to receive records on connection.
    Error   Failed to process connection. Reason: Exception has been thrown by the target of an invocation.

我不确定这意味着什么,并且取决于我做什么,我可以得到另一个错误,告诉我无法找到资源:

无法找到资源。

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.   Please review the following URL and make sure that it is spelled correctly.

请求的网址:/Default.aspx/ 版本信息:Mono Runtime版本:2.10.8(tarball Thu Aug 16 23:46:03 UTC 2012)ASP.NET版本:4.0.30319.1

如果我需要提供更多信息,请告诉我。

编辑:

我现在收到nginx网关错误。

我的nginx配置文件如下所示:

server {
    listen   2194;
    server_name localhost;
    access_log $HOME/WWW/nginx.log;

    location / {
      root $HOME/WWW/dev/;
      index index.html index.html default.aspx Default.aspx Index.cshtml;
      fastcgi_index Views/Home/; 
      fastcgi_pass 127.0.0.1:8000;
      include /etc/nginx/fastcgi_params;
    }
}

使用xsp4运行整个事情我已经发现了“调用目标已抛出异常”。

  

处理异常类型TargetInvocationException消息是异常   已经被调用的目标所抛出。 IsTerminating已设置   到True System.Reflection.TargetInvocationException:异常有   被调用的目标所抛出。

     

服务器堆栈跟踪:在System.Reflection.MonoCMethod.Invoke中   (System.Object obj,BindingFlags invokeAttr,
  System.Reflection.Binder binder,System.Object []参数,
  System.Globalization.CultureInfo culture)[0x00000] in:0,System.Reflection.MethodBase.Invoke(System.Object)   obj,System.Object []参数)[0x00000] in:0
  在System.Runtime.Serialization.ObjectRecord.LoadData   (System.Runtime.Serialization.ObjectManager经理,   ISurrogateSelector选择器,StreamingContext上下文)[0x00000] in   :0点   System.Runtime.Serialization.ObjectManager.DoFixups()[0x00000] in   :0点   System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject   (System.IO.BinaryReader reader)[0x00000] in:0
  在   System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph   (BinaryElement elem,System.IO.BinaryReader reader,Boolean   readHeaders,System.Object&结果,   System.Runtime.Remoting.Messaging.Header []&安培;标题)[0x00000] in   :0点   System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize   (System.IO.Stream serializationStream,   System.Runtime.Remoting.Messaging.HeaderHandler handler)[0x00000] in   :0点   System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize   (System.IO.Stream serializationStream)[0x00000] in:0 at   System.Runtime.Remoting.RemotingServices.DeserializeCallData   (System.Byte [] array)[0x00000] in:0 at(wrapper   xdomain-dispatch)System.AppDomain:DoCallBack(object,byte []&,byte []&)

     

在[0]处重新抛出异常:---> System.ArgumentException:无法   绑定到方法'SetHostingEnvironment'。在   System.Delegate.GetCandidateMethod(System.Type type,System.Type   target,System.String方法,BindingFlags bflags,Boolean ignoreCase,   Boolean throwOnBindFailure)[0x00000] in:0 at   System.Delegate.CreateDelegate(System.Type类型,System.Type目标,   System.String方法,Boolean ignoreCase,Boolean throwOnBindFailure)   [0x00000] in:在System.Delegate.CreateDelegate中为0   (System.Type类型,System.Type目标,System.String方法)[0x00000]   in:0 at   System.DelegateSerializationHolder + DelegateEntry.DeserializeDelegate   (System.Runtime.Serialization.SerializationInfo info)[0x00000] in   :System.DelegateSerializationHolder..ctor中的0   (System.Runtime.Serialization.SerializationInfo info,StreamingContext   ctx)[0x00000] in:0 at(包装器   managed-to-native)System.Reflection.MonoCMethod:InternalInvoke   (System.Reflection.MonoCMethod,object,object [],System.Exception&)at   System.Reflection.MonoCMethod.Invoke(System.Object obj,BindingFlags   invokeAttr,System.Reflection.Binder binder,System.Object []   参数,System.Globalization.CultureInfo文化)[0x00000] in   :0 ---内部异常堆栈跟踪结束---
  at(wrapper xdomain-invoke)System.AppDomain:DoCallBack   (System.CrossAppDomainDelegate)at(包装器   remoting-invoke-with-check)System.AppDomain:DoCallBack   (System.CrossAppDomainDelegate)at   System.Web.Hosting.ApplicationHost.CreateApplicationHost(System.Type   hostType,System.String virtualDir,System.String physicalDir)   [0x00000] in:0 at   Mono.WebServer.VPathToHost.CreateHost   (Mono.WebServer.ApplicationServer服务器,Mono.WebServer.WebSource   webSource)[0x00000] in:0 at   Mono.WebServer.XSP.Server.RealMain(System.String [] args,Boolean   root,IApplicationHost ext_apphost,Boolean quiet)[0x00000] in   :Mono.WebServer.XSP.Server.Main为0   (System.String [] args)[0x00000] in:0

2 个答案:

答案 0 :(得分:3)

在你的nginx配置中,执行此操作

fastcgi_index   /;

而不是:

fastcgi_index Default.aspx;

而不是:

fastcgi_index Views/Home/;

您希望mono fastcgi服务器查看基本请求。在mvc3-land中,没有Default.aspx,因为一切都是通过路由完成的。所以,也删除这一行:

index index.html index.html default.aspx Default.aspx Index.cshtml;

另一件可以真正咬你的事情是,对于运行时2 .dll的底层程序集引用已在项目引用的库中编译。

当我发现nuget的nhibernate引用实际上是3.5 .dlls时,我自己发现了这个。这使得它在一个库中只能加载一些类型,而其他类型则将实际发生的事情与疯狂无关的异常抛出。我通过使用csharp控制台找到了这个。

第一个让我陷入根本问题的例外是:

System.TypeLoadException: Could not load type
    at (wrapper managed-to-native) System.Type:type_is_assignable_from (System.Type,System.Type)

答案 1 :(得分:0)

404网址是“/Default.aspx /”

因为它/它在最后它正在寻找一个目录,我猜你想让它找一个文件Default.aspx而不是?

你的nginx配置阻止fastcgi连接是什么样的?

更新(在添加了请求的信息后):

http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_index解释了fastcgi_index指令。你设置它的方式有点奇怪你正在添加Views / Home / 到任何direcory的$ fastcgi_script_name。

您可能想将fastcgi_index设置为Default.aspx(然后它会将目录的任何请求作为目录/ default.aspx传递,我认为这是您想要的)

你也没有设置你的script_filename,单声道可能用它来知道要运行哪个文件(这就是它在任何情况下与php / ruby​​ fastcgi一起使用的方式)。

你可能想要在位置块中的nginx参数中使用以下内容:

fastcgi_index Default.aspx;
fastcgi_param SCRIPT_FILENAME $HOME/WWW/dev/home/$fastcgi_script_name;
fastcgi_pass 127.0.0.1:8000;
include /etc/nginx/fastcgi_params;

(如果我正确阅读你的教程,SCRIPT_FILENAME可能只是$ fastcgi_script_name)

另外,通常你会在服务器块级别设置一次索引和根指令,这样你就不必为每个位置块重复它,不过因为你只有一个位置块而不是真的很重要。