HyperFastCgi icon indicating copy to clipboard operation
HyperFastCgi copied to clipboard

app cannot be found - nginx on mac

Open jeffgabriel opened this issue 8 years ago • 7 comments

While it could certainly be my configuration, i am matching samples but just can't seem to get a response. Nginx serves the static web page OK when no fastcgi is configured.

OS: Mac OS X Yosemite NGinx: 1.9.4 Mono: 4.0.2 HyperFastCgi: 4 - built from master sources

server.config:

 <configuration>  
      <server type="HyperFastCgi.ApplicationServers.SimpleApplicationServer">   
           <host-factory>HyperFastCgi.HostFactories.SystemWebHostFactory</host-factory>  
           <threads min-worker="40" max-worker="0" min-io="4" max-io="0" />  
      </server>  
      <listener type="HyperFastCgi.Listeners.NativeListener">  
           <apphost-transport type="HyperFastCgi.Transports.NativeTransport"/>  
        <protocol>InterNetwork</protocol>  
        <address>127.0.0.1</address>  
        <port>9000</port>  
      </listener>  
   <apphost type="HyperFastCgi.AppHosts.AspNet.AspNetApplicationHost">  
           <log level="Debug" write-to-console="true" />  
           <add-trailing-slash>false</add-trailing-slash>  
   </apphost>  
   <web-applications>  
        <web-application>  
             <name>Web</name>  
             <vhost>localhost</vhost>  
             <vport>80</vport>  
             <vpath>/</vpath>  
             <path>/usr/local/var/www/</path>  
        </web-application>  
   </web-applications>  
 </configuration>  

nginx.conf:

http { upstream fastcgi_backend { server 127.0.0.1:9000; keepalive 32; } server { listen 80 default_server; server_name localhost; access_log /var/log/web.log; error_log /var/log/nginxerror.log;

location / { root /usr/local/var/www/; index index.html index.htm default.aspx Default.aspx; fastcgi_index index.html; fastcgi_keep_conn on; fastcgi_pass fastcgi_backend; include /usr/local/nginx/conf/fastcgi_params; } } } events { worker_connections 1024; }

run command:

hyperfastcgi4 /config=/usr/local/server.config /logfile=/usr/local/HyperFastCgi/logging.log /loglevels=Debug

Output: [2015-09-17 22:18:02Z] Debug HyperFastCgi libev.c:461: Listen(): libevent version: 2.0.22-stable libev.c:475: Listen(): libevent is using kqueue for events. fcgi-transport.c:394: parse_params(): Can't find app! HOST='localhost' port=80 path='/index.html'

jeffgabriel avatar Sep 18 '15 02:09 jeffgabriel

Please show the output of the hyperfastcgi4 command with loglevels=All

hyperfastcgi4 /config=/usr/local/server.config /logfile=/usr/local/HyperFastCgi/logging.log /loglevels=All

xplicit avatar Sep 18 '15 08:09 xplicit

Ah, that's more info...

What's the significance of the root directory? Is that being used to locate the assemblies?

[2015-09-18 08:15:46Z] Debug HyperFastCgi [2015-09-18 08:15:46Z] Debug Threadpool minw=40,minio=16,maxw=800,maxio=32 [2015-09-18 08:15:46Z] Debug Root directory: /usr/local [2015-09-18 08:15:47Z] Error Can't create host System.IO.FileNotFoundException: Could not load file or assembly 'HyperFastCgi, Version=0.4.4.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified. File name: 'HyperFastCgi, Version=0.4.4.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' at (wrapper xdomain-invoke) System.AppDomain:CreateInstanceAndUnwrap (string,string) at (wrapper remoting-invoke-with-check) System.AppDomain:CreateInstanceAndUnwrap (string,string) at System.Web.Hosting.ApplicationHost.CreateApplicationHost (System.Type hostType, System.String virtualDir, System.String physicalDir) [0x00000] in :0 at HyperFastCgi.HostFactories.SystemWebHostFactory.CreateApplicationHost (System.Type appHostType, System.String vhost, Int32 vport, System.String vpath, System.String path) [0x00000] in :0 at HyperFastCgi.ApplicationServers.SimpleApplicationServer.CreateAppHost (System.Type appHostType, System.Object appHostConfig, HyperFastCgi.Configuration.WebAppConfig appConfig, IListenerTransport listenerTransport, System.Type appHostTransportType, System.Object appHostTransportConfig) [0x00000] in :0 [2015-09-18 08:15:47Z] Debug Listening on port: 9000 [2015-09-18 08:15:47Z] Debug Listening on address: 127.0.0.1

jeffgabriel avatar Sep 18 '15 12:09 jeffgabriel

The most possible reason of the error that HyperFastCgi.dll is not registered in the GAC. Did you do make install to install the library? I've never checked installation procedure on Mac OS, because I don't have Mac, so there could be some issues.

root directory is the directory for configuration of web appplications. If you want to use relative paths of web application location in config, you can set up root directory in config.

xplicit avatar Sep 18 '15 14:09 xplicit

Yes, i used the same commands as on the instructions:

./autogen.sh --prefix=/usr make sudo make install

I used CakeBrew to install the automake/libtool/autoconf/glib dependencies and had to additionally run make install on libtool.

If there are logs you would be interested in, let me know. I went ahead and manually gac'd the exe, and now get a different log:

[2015-09-18 14:44:05Z] Debug HyperFastCgi [2015-09-18 14:44:05Z] Debug Threadpool minw=40,minio=16,maxw=800,maxio=32 [2015-09-18 14:44:05Z] Debug Root directory: /usr/local [2015-09-18 14:44:05Z] Error Can't create host System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

Server stack trace: at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in :0 at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in :0 at System.Activator.CreateInstance (System.Type type) [0x00000] in :0 at HyperFastCgi.AppHosts.AppHostBase.Configure (System.Object appHostConfig, System.Object webAppConfig, IApplicationServer server, IListenerTransport listenerTransport, System.Type appHostTransportType, System.Object transportConfig) [0x00000] in :0 at HyperFastCgi.AppHosts.AspNet.AspNetApplicationHost.Configure (System.Object appHostConfig, System.Object webAppConfig, IApplicationServer server, IListenerTransport listenerTransport, System.Type appHostTransportType, System.Object transportConfig) [0x00000] in :0 at (wrapper managed-to-native) System.Runtime.Remoting.RemotingServices:InternalExecute (System.Reflection.MethodBase,object,object[],object[]&) at System.Runtime.Remoting.RemotingServices.InternalExecuteMessage (System.MarshalByRefObject target, IMethodCallMessage reqMsg) [0x00000] in :0

Exception rethrown at [0]: ---> System.TypeInitializationException: An exception was thrown by the type initializer for HyperFastCgi.Transports.NativeTransport ---> System.MissingMethodException: Attempted to access a missing method. at (wrapper managed-to-native) HyperFastCgi.Transports.NativeTransport:RegisterTransport (System.Type) at HyperFastCgi.Transports.NativeTransport..cctor () [0x00000] in :0 --- End of inner exception stack trace --- at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in :0 --- End of inner exception stack trace --- at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy rp, IMessage msg, System.Exception& exc, System.Object[]& out_args) [0x00000] in :0 [2015-09-18 14:44:05Z] Debug Listening on port: 9000 [2015-09-18 14:44:05Z] Debug Listening on address: 127.0.0.1

jeffgabriel avatar Sep 18 '15 18:09 jeffgabriel

Hi, I have the same error, can you tell me how can it be solved? Thanks!

OC: CentOS7

#: LD_LIBRARY_PATH=/usr/local/lib hyperfastcgi4 /config=/etc/hyperfastcgi/hfc.config /loglevels=All

[2017-04-07 17:33:09Z] Debug HyperFastCgi libev.c:475: Listen(): libevent version: 2.0.21-stable libev.c:489: Listen(): libevent is using epoll for events. fcgi-transport.c:444: parse_params(): Can't find app! HOST='109.120.151.151' port=443 path='/index.aspx' fcgi-transport.c:444: parse_params(): Can't find app! HOST='109.120.151.151' port=443 path='/favicon.ico'

Nginx:

upstream fastcgi_backend {
     server 127.0.0.1:9000;    
     keepalive 80;
 }
  
   server {
         listen   80;
         server_name  109.120.151.151;
         return 301 https://$host$request_uri;
 }
  
 server {
          listen   443 ssl;
          server_name  109.120.151.151;
           
          ssl_certificate /etc/nginx/ssl/xxxx.crt;
          ssl_certificate_key /etc/nginx/ssl/xxx.key;
                   
          proxy_connect_timeout 600;
          proxy_read_timeout 600;
          proxy_send_timeout 600;
          send_timeout       600;
 
          location ~ /\.  { deny all; }
 
          location / {
                  root /var/www/wsteleport/;
                  index index.html index.htm default.aspx Default.aspx;
                  fastcgi_index index.aspx;
 		             fastcgi_keep_conn on;
                  fastcgi_pass fastcgi_backend;
                  include /etc/nginx/fastcgi_params;
                  
                  fastcgi_split_path_info ^((?U).+\.as.x)(/?.+)$;
 		             fastcgi_param PATH_INFO $fastcgi_path_info;
 		             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          }  
 }

HyperFastCGI:

<configuration>
    <server type="HyperFastCgi.ApplicationServers.SimpleApplicationServer">
        <host-factory>HyperFastCgi.HostFactories.SystemWebHostFactory</host-factory>
        <threads min-worker="80" max-worker="0" min-io="4" max-io="0" />
    </server>

<listener type="HyperFastCgi.Listeners.NativeListener">
    <apphost-transport type="HyperFastCgi.Transports.NativeTransport">
        <multithreading>ThreadPool</multithreading>
    </apphost-transport>
        <protocol>InterNetwork</protocol>
        <address>127.0.0.1</address>
        <port>9000</port>
    </listener>

    <apphost type="HyperFastCgi.AppHosts.AspNet.AspNetApplicationHost">
        <log level="Debug" write-to-console="true" />
        <add-trailing-slash>false</add-trailing-slash>
    </apphost>
    <web-applications>
        <web-application>
            <name>109.120.151.151</name>
            <vhost>109.120.151.151</vhost>
            <vport>80</vport>
            <vpath>/</vpath>
            <path>/var/www/wsteleport/</path>
        </web-application>
    </web-applications>
</configuration>

mherarsh avatar Apr 07 '17 22:04 mherarsh

@MherX This issue is unrelated to original, please open another one. In short this message means that your application declaration does not match to the host:port which are coming from nginx. In your case you listens on 443 and all requests come to 443 port, but you defined 80 vport in web-application element. That's why your application could not be found and hyperfastcgi shows error message.

xplicit avatar Apr 08 '17 07:04 xplicit

@xplicit tahnks, I open another issue: https://github.com/xplicit/HyperFastCgi/issues/81

mherarsh avatar Apr 08 '17 13:04 mherarsh