samedi 19 août 2017

Ruby on Rails ActionCable and Redis config using Passenger and Nginx

My ActionCable setup works perfectly in the development environment but it fails in production. For the server I am using Nginx and Phussion Passenger to manage my app.

I believe the issue lies within Redis configuration, my config/cable.yml file looks like this

production:
  adapter: redis
  url: redis://lordwaiter.com:6379

local: &local
  adapter: redis
  url: redis://localhost:6379

development: *local
test: *local

I have followed this guide for this implementation

Integrating Action Cable with Passenger + Nginx In the guide the example url for the redis is redis://redis.example.com:6379 so I tried changing mine to redis://redis.lordwaiter.com:6379 that didn't work as well.

My current config throws this error

Redis::CannotConnectError: Error connecting to Redis

I tried placing localhost instead my hostname like redis://localhost:6379 This time my request was handled without throwing any exceptions but I didn't receive any broadcast in the browser.

I think there needs to be a declaration for the redis url in nginx's virtual host file. I am clueless at this moment and I would highly appreciate any guidance over this.

My Nginx virtual host configuration for my host looks like this

server {

    server_name www.lordwaiter.com lordwaiter.com;
    listen 80;
    listen [::]:80;
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    # Tell Nginx and Passenger where your app's 'public' directory is
    root /var/www/lordwaiter/code/public;

    # Turn on Passenger
    passenger_enabled on;
    passenger_ruby /usr/local/rvm/gems/ruby-2.4.0/wrappers/ruby;

    ssl on;
    ssl_certificate /etc/ssl/cert_chain.crt;
    ssl_certificate_key /etc/ssl/private.key;

    location /cable {
        passenger_app_group_name lordwaiter_action_cable;
        passenger_force_max_concurrent_requests_per_process 0;
    }


}

Aucun commentaire:

Enregistrer un commentaire