FastCGI Application [Answered]RSS

4 replies

Last post May 10, 2010 02:38 AM by emanueldejanu

  • FastCGI Application

    May 04, 2010 10:23 AM|emanueldejanu|LINK

    I have a fast cgi application writen in C++. The extension is fcgi.

    Can somebody explain step by step how configure a fast cgi application to run when the user is accesing /path/cgi-bin/appname.fcgi.

     I have tried using iismgr to configure the fast cgi application but the FastCGI-Module require the application to end in .exe or .dll.

    All the tutorials are about PHP. But my application need to run in the same way a cgi application is accesed (/path/cgi-bin/appname.cgi) but under FastCGI control, to have full speed.

     Thanks.

     

  • Re: FastCGI Application

    May 04, 2010 07:39 PM|ksingla|LINK

    I understand appname.fcgi is actually an executable and you want to run it when a request to appname.fcgi is made. My recommendation will be to rename appname.fcgi to appname.exe and then set a handler for extension ".fcgi" which runs appname.exe. Comparing with PHP, appname.exe will be replacing php-cgi.exe and handler for fcgi will be similar to handler for php. See if this mapping makes it easier for you to use articles which are for PHP.

    Thanks,
    Kanwal

  • Re: FastCGI Application

    May 05, 2010 07:19 AM|emanueldejanu|LINK

     Kanwal,

     

    Thanks for your response. I have configured a new module mapping like this:

    1. Add Module Mapping... (on cgi-bin directory)

    • <div mce_keep="true">Request Path: appname.fcgi</div>
    • <div mce_keep="true">Module: FastCgiModule</div>
    • <div mce_keep="true">Executable (optional): C:\inetpub\wwwroot\cgi-bin\appname.exe</div>
    • <div mce_keep="true">Name: AppName</div>

    3. Request /cgi-bin/appname.fcgi/en/p/about

    I get the following enviroments:

    • <div mce_keep="true">PATH_INFO=/cgi-bin/appname.fcgi/en/p/about</div>
    • <div mce_keep="true">SCRIPT_NAME=/cgi-bin/appname.fcgi</div>

    I have a problem that PATH_INFO contains  "/cgi-bin/appname.fcgi". Because the application process this and give 404.

    I have this fast cgi application deployed on FreeBSD and Linux machines and the is PATH_INFO=/en/p/about

    Can somebody help me with this. I have allready changed the code to remove from PATH_INFO the SCRIPT_NAME but I do not like this.

     

  • Re: FastCGI Application

    May 06, 2010 05:43 PM|ksingla|LINK

    Yes, PATH_INFO set by IIS includes script name. Below is how PHP handles it it php-cgi.exe. You need to something similar in your FastCGI application.

      /* Hack for IIS that sets incorrect PATH_INFO */
      char *env_server_software = sapi_cgibin_getenv("SERVER_SOFTWARE", sizeof("SERVER_SOFTWARE")-1 TSRMLS_CC);
      if (env_server_software &&
       env_script_name &&
       env_path_info &&
       strncmp(env_server_software, "Microsoft-IIS", sizeof("Microsoft-IIS")-1) == 0 &&
       strncmp(env_path_info, env_script_name, strlen(env_script_name)) == 0
      ) {
       env_path_info = _sapi_cgibin_putenv("ORIG_PATH_INFO", env_path_info TSRMLS_CC);
       env_path_info += strlen(env_script_name);
       if (*env_path_info == 0) {
        env_path_info = NULL;
       }
       env_path_info = _sapi_cgibin_putenv("PATH_INFO", env_path_info TSRMLS_CC);
      }

    Thanks,
    Kanwal

  • Re: FastCGI Application

    May 10, 2010 02:38 AM|emanueldejanu|LINK

    Kanwal,

     I had made the modification allready as I posted. But I think that this is not nice or ok. It should work without modification on Windows like on Linux or other platforms. Do you know why this is implemented like this?

     Regards,

     Emanuel