nginxでERR_EMPTY_RESPONSE
nginxを使ってgoで書かれたWebサーバにリバースプロキシしていますが、タイトルのエラーでページが表示されません。
default.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
#root /usr/share/nginx/html;
#index index.html index.htm;
proxy_pass http://127.0.0.1:60000/;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
goのメイン関数
package main
import (
"github.com/labstack/echo"
mw "github.com/labstack/echo/middleware"
"github.com/thoas/stats"
"os"
)
func main() {
e := echo.New()
// Middleware.
e.Use(mw.Logger())
e.Use(mw.Recover())
e.Use(mw.Gzip())
s := stats.New()
e.Use(s.Handler)
// Index page.
e.Index("public/")
// Static files.
e.Static("/js", "public/js")
e.Static("/css", "public/css")
e.Static("/images", "public/images")
if port := os.Getenv("PORT"); port != "" {
e.Run(":" + port)
} else {
e.Run(":3000")
}
}
このGoのWebサーバプログラムは/var/www/html/[page-name]
以下に存在します。
ローカルで確認しましたがちゃんと表示されました。
アクセスしてみると
INFO|echo|127.0.0.1 GET / 200 51.487429ms 13820
INFO|echo|127.0.0.1 GET / 200 9.556293ms 13820
INFO|echo|127.0.0.1 GET / 200 8.84661ms 13820
このようにコンソールに表示されますが、ページが表示されません。なぜ表示されないのでしょうか。
nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
追記 error_log
2016/02/11 04:32:39 [notice] 29316#0: signal process started
2016/02/11 04:32:45 [alert] 23756#0: worker process 29319 exited on signal 11
2016/02/11 04:32:46 [alert] 23756#0: worker process 29324 exited on signal 11
2016/02/11 07:09:02 [error] 29320#0: *241 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.10.100, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:60000/", host: "192.168.10.105"
一部ですが上記にようなものがたくさん書かれていました。
サーバ側での80番ポートtcpdump結果
01:02:40.058334 IP (tos 0x0, ttl 64, id 33406, offset 0, flags [DF], proto TCP (6), length 471)
192.168.10.100.56136 > 192.168.10.105.http: Flags [P.], cksum 0x9494 (correct), seq 1:420, ack 1, win 4117, options [nop,nop,TS val 300422591 ecr 15850679], length 419
E....~@.@. ...
d..
i.H.P..Y....X...........
........GET / HTTP/1.1
Host: 192.168.10.105
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: ja,en-US;q=0.8,en;q=0.6