teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

・/etc/nginx/conf.d/*.conf で cable を再設定

2020/07/09 04:13

投稿

koki0502
koki0502

スコア19

title CHANGED
File without changes
body CHANGED
@@ -11,7 +11,7 @@
11
11
  ##エラー
12
12
  デベロッパーツールのコンソール
13
13
  ```
14
- WebSocket connection to 'wss://ドメイン/cable' failed: Error during WebSocket handshake: Unexpected response code: 404
14
+ WebSocket connection to 'wss://ドメイン/cable' failed: Error during WebSocket handshake: Unexpected response code: 502
15
15
  ```
16
16
  log/production.log
17
17
  ```
@@ -22,13 +22,23 @@
22
22
  `config/environments/prodution.rb`の
23
23
 
24
24
  1.`config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ]`を有効にしドメインを設定
25
+ 2./etc/nginx/conf.d/*.confに下記を追加
26
+ ```
27
+ location /cable {
28
+ proxy_pass https://0.0.0.0:3000/cable;
29
+ proxy_http_version 1.1;
30
+ proxy_set_header Upgrade websocket;
31
+ proxy_set_header Connection Upgrade;
32
+ proxy_set_header X-Real-IP $remote_addr;
33
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
34
+ }
35
+ ```
25
36
 
26
37
  ###ご教示頂きたい点
27
38
  他に必要な要素を教えていただきたい
28
39
 
29
40
  必要となりそうな要素を一通り検索した結果下記の3点が目にとまりましたが、使用しているものもあれば使用していないものもあり取捨選択が困難でした
30
41
  ・AWSのELB設定 (HTTP/HTTPSでのWebSockets通信はサポートしていない?)
31
- ・/etc/nginx/conf.d/*.conf で cable を設定
32
42
  ・redisの設定
33
43
 
34
44