Bad Gateway with nginx, mono and fastcgi on debian

I am struggling with an alternative mono.NET for Linux. Here is my metadata:

OS: Debian 7.6 alias Wheezy   (as virtual machine; host: Windows 7 Pro SP1)
nginx v1.6.1                  (installed from nginx repository)
mono v3.6.0                   (compiled from source)
mono-fastcgi-server4          (installed from Debian repositories)

      

nginx is working correctly; I've tested it without mono, so it shouldn't be a problem.

The problem occurs when I enable the fastcgi component in the nginxserver config: I get a 502 Bad Gateway.

For your information, all of these configuration files that I have edited so far. I think these are the important ones:

/etc/nginx/conf.d/default.conf

server {
   listen        80;
   server_name   myserver.net;
   root          /var/www/myserver.net;
   index         index.html;

      location / {
         fastcgi_index   index.html;
         fastcgi_pass    127.0.0.1:9000;
         include         /etc/nginx/fastcgi_params;
      }
}

      

/ etc / nginx / fastcgi_params (original, except for these two lines) :

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

      

/etc/init.d/mono-fastcgi/myserver.net.webapp

<apps>
<web-application>
   <name>myserver.net</name>
   <vhost>*</vhost>
   <vport>80</vport>
   <vpath>/</vpath>
   <path>/var/www/myerver.net/</path>
</web-application>
</apps>

      

mono-fastcgi-server4 startup-command (split over multiple lines for review)

fastcgi-mono-server4
  --appconfigdir /etc/init.d/mono-fastcgi
  /socket=tcp:127.0.0.1:9000
  /logfile=/var/log/mono/fastcgi.log &

      

I really don't know why I &

should be there at the end, but without it the command won't work. Any suggestions?

I think this is all the information I can share with you. If something is missing, please provide it and I will add the information as soon as possible.

EDIT: I forgot to add fastcgi.log and nginx-logs :

/var/log/mono/fastcgi.log

[2014-09-04 10:39:20Z] Error   ERROR PROCESSING REQUEST: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.WebServer.FastCgi.WorkerRequest

Server stack trace: 
  at Mono.WebServer.FastCgi.ApplicationHost.ProcessRequest (Mono.WebServer.FastCgi.Responder responder) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at (wrapper xdomain-dispatch) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (object,byte[]&,byte[]&)

Exception rethrown at [0]: 
 ---> System.InvalidCastException: Cannot cast from source type to destination type.
  at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <filename unknown>:0 
  at Mono.WebServer.FastCgi.WorkerRequest..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at (wrapper xdomain-invoke) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at Mono.WebServer.FastCgi.Responder.Process () [0x00000] in <filename unknown>:0 
[2014-09-04 10:39:20Z] Error   Failed to process connection. Reason: The object was used after being disposed.
[2014-09-04 10:39:20Z] Notice  Beginning to receive records on connection.
[2014-09-04 10:39:20Z] Error   ERROR PROCESSING REQUEST: System.TypeInitializationException: An exception was thrown by the type initializer for Mono.WebServer.FastCgi.WorkerRequest

Server stack trace: 
  at Mono.WebServer.FastCgi.ApplicationHost.ProcessRequest (Mono.WebServer.FastCgi.Responder responder) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at (wrapper xdomain-dispatch) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (object,byte[]&,byte[]&)

Exception rethrown at [0]: 
 ---> System.InvalidCastException: Cannot cast from source type to destination type.
  at System.Configuration.ConfigurationManager.get_AppSettings () [0x00000] in <filename unknown>:0 
  at Mono.WebServer.FastCgi.WorkerRequest..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at (wrapper xdomain-invoke) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at (wrapper remoting-invoke-with-check) Mono.WebServer.FastCgi.ApplicationHost:ProcessRequest (Mono.WebServer.FastCgi.Responder)
  at Mono.WebServer.FastCgi.Responder.Process () [0x00000] in <filename unknown>:0 
[2014-09-04 10:39:20Z] Error   Failed to process connection. Reason: The object was used after being disposed.

      

/var/log/nginx/access.log

10.0.2.147 - - [04/Sep/2014:10:39:20 +0200] "GET /default.aspx HTTP/1.1" 502 574 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36" "-"
10.0.2.147 - - [04/Sep/2014:10:39:20 +0200] "GET /favicon.ico HTTP/1.1" 502 574 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36" "-"

      

/var/www/nginx/error.log

2014/09/04 10:39:20 [error] 2928#0: *11 upstream sent unexpected FastCGI record: 3 while reading response header from upstream, client: 10.0.2.147, server: lexekon.net, request: "GET /default.aspx HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "lexekon.net"
2014/09/04 10:39:20 [error] 2928#0: *11 upstream sent unexpected FastCGI record: 3 while reading response header from upstream, client: 10.0.2.147, server: lexekon.net, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "lexekon.net"

      

+3


source to share





All Articles