【发布时间】:2015-01-08 07:40:39
【问题描述】:
我的葡萄应用程序在 localhost 上运行,如下所示: bundle exec rackup -p 9292
之后去http://localhost:9292/api/v1/ping,
你会收到一个 json 响应 {"res":"pong"}
现在,我正在尝试在生产中进行设置。所以我决定在 puma 和 nginx 配置上运行它。 安装 puma 并在套接字上运行它。
⇒ bundle exec puma -b unix:///tmp/my_app.sock
Puma starting in single mode...
* Version 2.10.2 (ruby 2.1.2-p95), codename: Robots on Comets
* Min threads: 0, max threads: 16
* Environment: development
env :: development
Service started, go to town.
* Listening on unix:///tmp/my_app.sock
Use Ctrl-C to stop
使用如下配置设置 nginx:
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
upstream my_app {
server unix:///tmp/my_app.sock;
}
server {
listen 8989;
server_name my_app;
root /Volumes/dev/my_app;
access_log /Volumes/dev/my_app/service/log/host.access.log;
error_log /Volumes/dev/my_app/service/log/error.access.log;
location / {
root /Volumes/dev/my_app/;
gzip_static on;
expires max;
add_header Cache-Control public;
}
}
我希望它也能起到同样的作用。我浏览到
http://localhost:8989/api/v1/ping
但是从 nginx 得到了404 Not Found。
错误日志显示:
2015/01/07 21:51:15 [error] 62300#0: *2 open() "/Volumes/dev/my_app/api/v1/ping" failed (2: No such file or directory), client: 127.0.0.1, server: my_app, request: "GET /api/v1/ping HTTP/1.1", host: "localhost:8989"
也许它认为它是服务静态内容?
【问题讨论】:
标签: ruby json sockets nginx puma