Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8597707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:58:24+00:00 2026-06-12T00:58:24+00:00

I’m trying to write a c++ fastcgi program to be served by nginx. I’ve

  • 0

I’m trying to write a c++ fastcgi program to be served by nginx. I’ve got the program compiling, and the hello world example works, but I can’t seem to get any of the environment variables (REQUEST_METHOD), etc. from nginx. As far as I can tell, I’m following tutorials and have the same configuration, so I’m really pulling out my hair here as to why it’s not working. Here’s my configuration:

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

(the fastcgi_params is unchanged from the default nginx install).

Then the relevant code from the c++ program:

streambuf * cin_streambuf  = cin.rdbuf();
streambuf * cout_streambuf = cout.rdbuf();
streambuf * cerr_streambuf = cerr.rdbuf();

FCGX_Request request;

FCGX_Init();
FCGX_InitRequest (&request, 0, 0);

while (FCGX_Accept_r (&request) == 0)
{
  fcgi_streambuf cin_fcgi_streambuf (request.in);
  fcgi_streambuf cout_fcgi_streambuf (request.out);
  fcgi_streambuf cerr_fcgi_streambuf (request.err);

#if HAVE_IOSTREAM_WITHASSIGN_STREAMBUF
  cin  = &cin_fcgi_streambuf;
  cout = &cout_fcgi_streambuf;
  cerr = &cerr_fcgi_streambuf;
#else
  cin.rdbuf(&cin_fcgi_streambuf);
  cout.rdbuf(&cout_fcgi_streambuf);
  cerr.rdbuf(&cerr_fcgi_streambuf);
#endif

  //figure out what kind of request we have
  char * request_type = FCGX_GetParam("REQUEST_METHOD", request.envp);

  cout << "Content-type: text/html\r\n"
  "\r\n";
  cout << "Environment is: " << *request.envp;

}

The call to FCGX_GetParam returns null, and when I output the request.envp, the only variable shown is FCGI_ROLE=RESPONDER.

I’m using the following command to launch the process:

spawn-fcgi -p 9000 -n FCGI-App

Everything is running under Ubuntu 11.10.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:58:26+00:00Added an answer on June 12, 2026 at 12:58 am

    You are trying to print char **envp; with cout << *request.envp. This is expected to print only first string from the array, no surprise here.

    Try the code form official FCGI example instead:

    static void penv(const char * const * envp)
    {
        cout << "<PRE>\n";
        for ( ; *envp; ++envp)
        {
            cout << *envp << "\n";
        }
        cout << "</PRE>\n";
    }
    
    ...
    
    penv(request.envp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i got an object with contents of html markup in it, for example: string
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.