繁体   English   中英

nginx坏网关502与mono fastcgi

[英]nginx bad gateway 502 with mono fastcgi

你好,所以我一直试图让我的网站运行在mono(在ubuntu服务器上),我已经按照这些教程几乎到了这封信:

但是当我的目录不是空白时,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.

请求的URL:/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文化)[0x00000] in:0在System.Reflection.MethodBase.Invoke(System.Object obj,System.Object []参数)[0x00000] in:0
在System.Runtime.Serialization.ObjectRecord.LoadData(System.Runtime.Serialization.ObjectManager manager,ISurrogateSelector selector,StreamingContext context)[0x00000] in:0 at 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&result,System.Runtime.Remoting.Messaging.Header []&headers)[0x00000] in:0在System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize(System.IO.Stream serializationStream,System.Runtime.Remoting.Messaging.HeaderHandler handler)[0x00000] in:0 at 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类型,System.Type目标,System.String方法,BindingFlags bflags,Boolean ignoreCase,Boolean throwOnBindFailure)[0x00000] in:0 at System.Delegate.CreateDelegate(System.Type type,System .Type target,System.String方法,Boolean ignoreCase,Boolean throwOnBindFailure)[0x00000] in:0 at System.Delegate.CreateDelegate(System.Type type,System.Type target,System.String method)[0x00000] in:0 at System.DelegateSerializationHolder + DelegateEntry.DeserializeDelegate(System.Runtime.Serialization.SerializationInfo info)[0x00000] in:0 in System.DelegateSerializationHolder..ctor(System.Runtime.Serialization.SerializationInfo info,StreamingContext ctx)[0x00000] in:0 at (包装器托管到本机)System.Reflection.MonoCMethod:System.Reflection.MonoCMethod.Invoke中的InternalInvoke(System.Reflection.MonoCMethod,object,object [],System.Exception&)(System.Object obj,BindingFlags invokeAttr,System .Reflection.Binder binder,System.O bject []参数,System.Globalization.CultureInfo文化)[0x00000] in:0 ---内部异常堆栈跟踪结束---
at(wrapper xdomain-invoke)System.AppDomain:DoCallBack(System.CrossAppDomainDelegate)at(wrapper remoting-invoke-with-check)System.Web.Hosting.ApplicationHost.CreateApplicationHost上的System.AppDomain:DoCallBack(System.CrossAppDomainDelegate) .Type hostType,System.String virtualDir,System.String physicalDir)[0x00000] in:0 at Mono.WebServer.VPathToHost.CreateHost(Mono.WebServer.ApplicationServer server,Mono.WebServer.WebSource webSource)[0x00000] in:0 at Mono.WebServer.XSP.Server.RealMain(System.String [] args,布尔根,IApplicationHost ext_apphost,布尔安静)[0x00000] in:0 at Mono.WebServer.XSP.Server.Main(System.String [] args) [0x00000] in:0

在你的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)

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)

顺便说一下,通常你会在服务器块级别设置一次索引和根指令,这样你就不必为每个位置块重复它,但是因为你只有一个位置块它并不重要。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM