bash fastcgi输出内容类型

使用bash写fastcgi程序时,一定要先输出Content-type和一个空行,不然nginx会报错502 Bad Gateway,后台访问日志中会有”upstream prematurely closed FastCGI stdout while reading response header from upstream”错误。

下面两种写法皆可:

#!/bin/bash 

echo -e "Content-type: text/html\n"

或者

#!/bin/bash 

echo "Content-type: text/html"
echo ""

之后可以继续输出text或者html文本

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.