nginx一个fastcgi的demo错误

来源:互联网 发布:淘宝网页登陆 编辑:程序博客网 时间:2024/05/16 12:23

2016/03/23 18:29:22 [error] 3556#0: *6 upstream prematurely closed FastCGI stdout while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /main.cgi HTTP/1.1", upstream: "fastcgi://127.0.0.1:8081", host: "127.0.0.1".


一直都是OK 的,突然改了一下代码就乱了,实在不明白,检查了半天,才发现,原来我把 HTTP头输出给屏蔽掉了,也是醉了


n = sprintf(sendline,"Content-type: text/html\r\n"
                "\r\n"
                "<title>FastCGI Hello!</title>"
                "<h1>FastCGI Hello!</h1>"
                "Request number %d running on host <i>%s</i>\n",
                ++count, getenv("SERVER_NAME"));


                printf("%s",sendline);


一定要先输出头,否则nginx会直接屏蔽

0 0
原创粉丝点击