Created
August 11, 2017 11:04
-
-
Save kirankarki/a05c7902e40e2777ec8ed8c66b3765a5 to your computer and use it in GitHub Desktop.
Deploying ActionCable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<< Deploying ActionCable >> | |
1. Install redis-server | |
> sudo apt-get install redis-server | |
2. Check redis-server is installed or not | |
> redi-server | |
3. Mount actioncable url in 'routes.rb' | |
> Add following line to 'routes.rb' | |
> mount ActionCable.server => "/cable" | |
4. Set cable's url in cable.js file | |
> Parse '/cable' to Actioncable.createconsumer method. | |
5. Set remote origin url of action cable | |
> Paste following lines to 'production.rb' file | |
> config.action_cable.url = 'ws://<Server IP>/cable' | |
> config.action_cable.allowed_request_origins = ["http://<Server IP>"] | |
> config.action_cable.disable_request_forgery_protection = true | |
If you end with "Webscoked failed to handshake" error in browser's console tab, check your nginx config for "Action Cable" according to below: | |
location /cable { | |
proxy_pass http://puma; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "Upgrade"; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-Proto https; | |
proxy_redirect off; | |
} | |
< Urls > | |
https://gorails.com/deploy/actioncable | |
https://deanpcmad.com/2017/rails-5-actioncable-nginx-and-puma-in-production/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment