【发布时间】:2019-05-14 18:00:11
【问题描述】:
我目前正在 ubuntu 服务器上安装我的应用程序。我想知道为什么,当我尝试访问我的 API 时,nginx 会返回 404。
我已经配置了thin 和nginx,但我不知道为什么这不起作用,并且作为这个领域的新手我承认我不知道从哪里开始。
我尝试更改瘦配置和 nginx 配置,但没有任何效果。
精简配置
user: www-data
group: www-data
pid: tmp/pids/thin.pid
timeout: 30
wait: 30
log: log/thin.log
max_conns: 1024
require: []
environment: production
max_persistent_conns: 512
servers: 1
threaded: true
no-epoll: true
address: 0.0.0.0
port: 3000
daemonize: true
chdir: /home/ubuntu/happer-api
tag: happer-api
Nginx 配置
upstream myapp {
server 127.0.0.1:3000;
server 127.0.0.1:3001;
server 127.0.0.1:3002;
}
server {
listen 80;
server_name .example.com;
access_log /home/ubuntu/happer-api/log/access.log;
error_log /home/ubuntu/happer-api/log/error.log;
root /home/ubuntu/happer-api;
index index.html;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
try_files /system/maintenance.html $uri $uri/index.html $uri.html @ruby;
}
location @ruby {
proxy_pass http://myapp;
}
}
我在 EC2 实例上,我使用亚马逊工具打开端口
我的 API 上也有活跃的管理员,但我无法访问它。
【问题讨论】: