【发布时间】:2021-02-12 14:56:54
【问题描述】:
我正在使用 Nginx Web 服务器和 Puma Application Server 设置 Rails 6 应用程序。
我希望 Nginx 网络服务器提供静态网络文件,而 Puma 应用程序服务器将处理动态请求。
我已经设置了 Nginx,这是我的 Rails 6 应用程序的 Nginx 配置文件:
upstream railsserver {
server 127.0.0.1:3000;
}
server {
# Replace 'localhost' with your FQDN if you want to use
# your app from remote or if you need to add a certificate
server_name localhost;
root /home/deploy/my-website/public;
# Define where Nginx should write its logs
access_log /var/log/nginx/my-website/access.log;
error_log /var/log/nginx/my-website/error.log;
location / {
try_files $uri $uri/ @railsserver;
}
location ~ ^/(assets/|robots.txt|humans.txt|favicon.ico) {
expires max;
}
location @railsserver {
proxy_set_header Host $http_host;
proxy_set_header CLIENT_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 300;
proxy_pass http://railsserver;
gzip on;
gzip_types text/plain text/xml text/css image/svg+xml application/javas$
gzip_proxied any;
}
}
我也用命令重启了Nginx:
sudo systemctl restart nginx
但每次我尝试通过浏览器访问该网站时,都会出现错误:
404 页面未找到
我似乎无法弄清楚错误来自哪里。
【问题讨论】:
标签: ruby-on-rails nginx puma