# Nginx-FastCGI-C++

**URL:** <https://www.ruby-forum.com/t/nginx-fastcgi-c/200323>\
**Category:** NGINX\
**Created:** [December 9, 2010, 9:47am UTC](https://www.ruby-forum.com/t/nginx-fastcgi-c/200323 "2010-12-09T09:47:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [December 9, 2010, 9:47am UTC](https://www.ruby-forum.com/t/nginx-fastcgi-c/200323/1 "2010-12-09T09:47:15Z")

</div>

Hello nginx,

I have a Fastcgi C++ program as follow:

1 #include “fcgi\_stdio.h”  
2 #include \<stdlib.h\>  
3  
4 int main(void)  
5 {  
6 int count = 0;  
7 while(FCGI\_Accept() \>= 0)  
8 printf(“Content-type: text/html\r\n”  
9 “\r\n”  
10 “

# Tiny3
”  
11 “
# FastCGI World!
”  
12 “Request number %d running on host _%s_\n”,  
13 ++count, getenv(“SERVER\_NAME”));  
14 return 1;  
15 }

then i have modified the Nginx conf file

30 upstream fastcgiends{  
31 server 127.0.0.1:9110 weight=1 max\_fails=2 fail\_timeout=30s;  
32 server 127.0.0.1:9111 weight=1 max\_fails=2 fail\_timeout=30s;  
33 }

location =/3.cgi {  
#fastcgi\_pass 127.0.0.1:9110;  
fastcgi\_pass fastcgiends;  
}

If I use fastcgi\_pass 127.0.0.1:9110;, it can work normal, but I want  
to  
use the nginx’s balance performance ,so to use the fastcgi\_pass  
fastcgiends;, it can’t work.

start the spawn-fcgi command :

spawn-fcgi -a 127.0.0.1 -p 9110 -f ./tiny3 -P ./pid/fastcgi\_9110.pid  
spawn-fcgi -a 127.0.0.1 -p 9111 -f ./tiny3 -P ./pid/fastcgi\_9111.pid

but I found i can’t query it from the web

[http://122.36.180.89:9095/3.cgi](http://122.36.180.89:9095/3.cgi) [http://122.36.180.89:9095/3.cgi](http://122.36.180.89:9095/3.cgi)

and does anyone konw sth about this problem ?

It is posted at [Nginx-FastCGI-C++](http://forum.nginx.org/read.php?2,157079)

Thanks

Kevinew
