お知らせ

  • 利用規約を守って投稿してください。また、よくある質問および投稿の手引きも参照してください。
  • メッセージの投稿にはアカウントが必要です。未登録の方は、ユーザ登録ページからアカウントを作成することができます。

#1 2012-07-16 14:45:22

infinity-dimensions
新しいメンバ
From: Sendai, Miyagi, Japan
登録日: 2010-04-10

12.04+nginx+fcgiwrapで502 upstream closed prematurelyエラー

VPSにサーバー環境作って運用しているのですが、PerlをFastCGIで実行しようとすると「upstream closed prematurely~」のエラー吐いてうまく動きません。約1ヶ月かかって調べてますが原因がつかめず…

・Ubuntu Server 12.04 LTS amd64(Japanese Team)
・Nginx 1.19-1
・Perl(FastCGI)

Nginxはaptitudeコマンドでインストールして仮想ホストも無事に動いている状態です。
その上で Nginx and Perl-FastCGI on Ubuntu 11.04 (Natty) – Linode Library  の記事に沿ってPerl(FastCGI)を導入。
その前に Nginx and PHP-FastCGI on Ubuntu 11.04 (Natty) – Linode Library の記事に従って導入したPHPは普通に稼働しています。

Nginxのアクセスログを確認すると502エラーを吐いており、エラーログを確認すると

コード:

2012/07/15 23:51:07 [error] 26413#0: *28 upstream closed prematurely FastCGI stdout while reading response header from upstream, client: [IPアドレス], server: [ホストドメイン], request: "GET /test.cgi HTTP/1.1", upstream: "fastcgi://127.0.0.1:8999", host: "[ホストドメイン]"

「upstream closed prematurely~」のエラー吐いていました。


・Nginxの設定[nginx.conf]

コード:

user www-data;
worker_processes 1;
pid /var/run/nginx.pid;

events {
  worker_connections 1024;
  # multi_accept on;
}

http {
  ##Basic Settings
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;

  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  ##Gzip Settings
  gzip on;
  gzip_disable "msie6";

  ##Virtual Host Configs
  include /etc/nginx/sites-enabled/*;
}

・バーチャルホストの設定

コード:

server {
  root [rootディレクトリ]l;
  index index.html index.htm index.cgi;
  server_name [ホストドメイン];
  access_log  [ホストドメイン]/log/host.access.log;
  error_log  [ホストドメイン]/log/error.log;

  location / {
    try_files $uri $uri/ /index.html;
  }

  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
    root /usr/share/nginx/www;
  }

  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }

  #Perl scripts to FastCGI
  location ~ \.cgi$ {
    gzip off;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:8999;
    fastcgi_index index.cgi;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    #いろんなサイト見て突っ込んでみました
    fastcgi_ignore_client_abort on;
    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
  }
}

・fcgiwrapの設定抜粋

コード:

FCGI_CHILDREN="6"
FCGI_PORT="8999"
FCGI_ADDR="127.0.0.1"
FCGI_USER="www-data"
FCGI_GROUP="www-data"
FCGI_SOCKET_OWNER="www-data"
FCGI_SOCKET_GROUP="www-data"

. /lib/lsb/init-functions

DIETIME=15
QDIETIME=1

・test.cgi(755)

コード:

#!/usr/bin/perl

print "Content-type:text/html\n\n";
print "Hellow World";

「upstream closed prematurely」とか「ubuntu nginx Perl FastCGI 502 error」なんかのキーワードで海外コミュニティもずいぶんのぞいてみましたがハッキリした原因はわからず。
リソース不足も確認しましたがそれは無いかと思います。
まだ12.04のリリースから間もないこともあって情報不足気味です。バグなのかどうかもハッキリしていないのでなんとも…

稚拙な内容で申し訳ございませんが、ご理解のある方いらっしゃればよろしくお願い致します。

オフライン

 

Board footer

Powered by FluxBB