aso*_*erg 2 linux unicode ubuntu ruby-on-rails nginx
我有一个 nginx 设置,配置为与 Unicorn 上游(它是一个 Rails 应用程序)对话。我已经检查了基础知识。我知道请求正在发送到 nginx,它映射到 server_name,它找到 try_files 指令,它会转到最后一个指令,即 @unicorn 映射到位置块。在位置块中我有这个:
location @unicorn {
# an HTTP header important enough to have its own Wikipedia entry:
# http://en.wikipedia.org/wiki/X-Forwarded-For
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# this helps Rack set the proper URL scheme for doing HTTPS redirects:
proxy_set_header X-Forwarded-Proto $scheme;
# pass the Host: header from the client right along so redirects
# can be set properly within the Rack application
proxy_set_header Host $http_host;
# we don't want nginx trying to do something clever with
# redirects, we set the Host: header above already.
proxy_redirect off;
proxy_pass http://unicorn_myapp;
}
Run Code Online (Sandbox Code Playgroud)
然后进一步查看我的文件
upstream unicorn_myapp {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
server unix:/etc/sockets/unicorn.myapp.sock;
}
Run Code Online (Sandbox Code Playgroud)
我也有独角兽在同一个套接字上监听。这是我的独角兽配置文件中的一个片段:
# Use at least one worker per core if you're on a dedicated server,
# more will usually help for _short_ waits on databases/caches.
worker_processes 2
# Help ensure your application will always spawn in the symlinked
# "current" directory that Capistrano sets up.
working_directory "/home/deployer/apps/myapp/current"
# listen on both a Unix domain socket
# we use a shorter backlog for quicker failover when busy
listen "/etc/sockets/unicorn.myapp.sock", :backlog => 64
Run Code Online (Sandbox Code Playgroud)
我已经验证两个守护进程都在运行,套接字文件存在(例如独角兽正在监听)并且不存在权限问题,因为这会被记录。说到日志,每当我请求根目录时,nginx 都会返回以下内容:
HTTP/1.1 301 Moved Permanently
Server: nginx/1.4.6
Date: Sun, 30 Mar 2014 21:05:55 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Status: 301 Moved Permanently
Location: https://myapp.com
Run Code Online (Sandbox Code Playgroud)
这会记录在 nginx 的访问日志中:
xx.xx.xx.xx - - [30/Mar/2014:17:05:55 -0400] "GET / HTTP/1.1" 301 5 "-" "-"
Run Code Online (Sandbox Code Playgroud)
Unicorn 的日志中没有任何内容。这里可能发生了什么?
归档时间: |
|
查看次数: |
1348 次 |
最近记录: |