ruby-on-rails - Nginx+puma 部署
问题描述
早上好!
我正在尝试使用 Nginx 部署 Puma 服务器。到目前为止,我已经设法创建了 Puma 服务器,正如我的进程表所示ps aux | grep puma
:
superad+ 5005 0.0 0.4 73076 17244 ? Sl May27 0:02 puma 3.11.4 (unix:///var/www/womaclub.com/shared/tmp/sockets/puma.sock)
superad+ 5020 0.0 1.8 591892 71980 ? Sl May27 0:06 puma: cluster worker 0: 5005
superad+ 5023 0.0 1.8 591816 71656 ? Sl May27 0:05 puma: cluster worker 1: 5005
但是,我无法让 Nginx 重定向并为我的应用程序提供服务。这是我的 nginx 配置文件:
upstream puma {
server unix:///var/www/womaclub.com/shared/tmp/sockets/puma.sock;
}
server {
listen 443 ssl;
server_name womaclub.com www.womaclub.com;
ssl_certificate /etc/letsencrypt/live/womaclub.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/womaclub.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
root /var/www/womaclub.com/current/public;
access_log /var/www/womaclub.com/shared/log/puma_access.log;
error_log /var/www/womaclub.com/shared/log/puma_error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass https://puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 10M;
keepalive_timeout 10;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
if ($scheme != "https") {
return 301 https://$host$request_uri;
} # managed by Certbot
# Redirect non-https traffic to https
# if ($scheme != "https") {
# return 301 https://$host$request_uri;
# } # managed by Certbot
}
我尝试了多种配置,但直到现在我都无法解决这个问题。任何帮助将非常感激,
谢谢!
解决方案
推荐阅读
- spring-security - 实现 PersistentTokenBasedRememberMeServices 的正确方法
- codeigniter - Sendgrid 事件通知 POST 数据始终为空
- python - 如何在 Django 中创建自更新变量?
- opticalflow - 给定每帧的一组像素单元,如何测量两帧之间的差异?
- react-select - 我们可以以编程方式删除 react-select 中的选定选项之一吗?
- linux - 即使我注册了一个环境变量,它也说无法加载so文件。我应该怎么办?
- reactjs - gh-pages 分支没有来自 master 的最新部署和提交
- c# - 定义整数范围的组合/排列的 C# 算法
- swift - 使用 oauthSwift 的无效随机数和时间戳 Garmin 访问令牌 API 响应
- c# - new Task() 中的 await Task.Delay(1000) 是否会阻塞某些线程?