首页 > 解决方案 > 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
}

我尝试了多种配置,但直到现在我都无法解决这个问题。任何帮助将非常感激,

谢谢!

标签: ruby-on-railsnginxpuma

解决方案


推荐阅读