我在VPS上设置了一个服务器,通过Nginx + Unicorn为生产Rails应用程序提供服务。 目前这个工作正常与以下conf文件:
但是, staging.appname.tld添加的子域最终会在/var/log/nginx/error.log产生以下错误:
2012/08/20 16:57:39 [error] 24673#0: *174 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: staging.appname.com, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.appname_staging.sock:/", host: "staging.appname.com" 2012/08/20 16:58:17 [error] 24673#0: *178 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: staging.appname.com, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.appname_staging.sock:/", host: "staging.appname.com" 2012/08/20 16:59:29 [error] 24673#0: *182 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: staging.appname.com, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.appname_staging.sock:/", host: "staging.appname.com"
引发这个错误的configuration是:
此外,袜子确实存在! 如果我们查看/ tmp /我们看到: unicorn.appname.sock和unicorn.appname_staging.sock
这里是nginx -V输出。
这似乎是configuration中的东西,但是我只是没有看到它。 有人可以请告知,这个错误是从哪里来的,以及如何在这种情况下正确地设置子域,例如临时环境?
我没有看到你的configuration中有什么不对,虽然有一些细微的东西来改善,但没有什么应该打破它。 你可以请激活debugging日志logging,并在这里发布日志。
请查看以下修改的configuration(激活debugging日志logging)。
upstream unicorn_appname_staging { server unix:/tmp/unicron.appname_staging.sock max_fails=0; } server { listen 80; index index.html; root /home/deployer/apps/appname/staging/current/public; server_name staging.appname.com; client_max_body_size 4G; keepalive_timeout 10; access_log /var/log/nginx/staging.appname.com.access.log; error_log /var/log/nginx/staging.appname.com.error.log debug; error_page 500 502 503 504 /500.html; location / { location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; } try_files $uri @unicorn_appname_staging; } location @unicorn_appname_staging { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_redirect off; proxy_pass http://unicorn_appname_staging; } }