基于SSL的nginx转发rails7 puma websocket的cable


1. 前端Nginx分发服务器

        location /cable {
                proxy_pass http://delitao_backend;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $host;
                proxy_redirect off;
                proxy_set_header   X-Forwarded-Proto https;

        }
2. 应用服务器
        location /cable {
                proxy_pass http://delitao;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $host;
        }
3. Rails config/production.rb
 45   config.action_cable.url = "wss://delitao.com/cable"
 46   config.action_cable.allowed_request_origins = [ "https://delitao.com", /https:\/\/delitao.*/ ]
 48   # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
 49   config.force_ssl = true                                                                                                                           
 50 

阅读量: 45
发布于:
修改于: