Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache nginx连接后的phoenix websocket被拒绝_Apache_Nginx_Channel_Phoenix - Fatal编程技术网

Apache nginx连接后的phoenix websocket被拒绝

Apache nginx连接后的phoenix websocket被拒绝,apache,nginx,channel,phoenix,Apache,Nginx,Channel,Phoenix,无法使用nginx之前的apache反向代理使凤凰频道在nginx之后工作 网站正常,但无法建立套接字连接。socket在dev模式下一切正常。phoenix中没有授权设置 defp authorized?(_payload) do true end 错误消息为 2017/04/29 09:40:50 [error] 10451#10451: failed (111: Connection refused) while connecting to upsteam, client:

无法使用nginx之前的apache反向代理使凤凰频道在nginx之后工作

网站正常,但无法建立套接字连接。socket在dev模式下一切正常。phoenix中没有授权设置

defp authorized?(_payload) do
    true
 end
错误消息为

2017/04/29 09:40:50 [error] 10451#10451: failed (111: Connection refused) 
while connecting to upsteam, client: 192.168.0.10, 
server: somehost.com, 
request: "GET /socket/websocket?token=undefined&vsn=1.0.0 HTTP/1.1",
upstream:"http://phoenix3/socket/websocket?token=undefined&vsn=1.0.0", 
host: "somehost.com"
根据本主题的指南,这里是我提出的设置

在user_socket.ex中

transport :websocket, Phoenix.Transports.WebSocket, check_origin: ["//somehost.com"]
终点

config :myapp, MyApp.Endpoint,                                               
  http: [port: {:system, "PORT"}],                                                   
  url: [host: "somehost.com", port: 80],                               
  cache_static_manifest: "priv/static/manifest.json"  
在nginx中

nbX-Real-IP或X-Cluster-Client-IP都失败

upstream phoenix3 {                                                                  
   server localhost:4020 max_fails=5 fail_timeout=60s;                           
}                                                                                    
map $http_upgrade $connection_upgrade {                                             
 default upgrade;                                                            
 '' close;                                                                   
}                                                                                    
server {                                                                             
  listen 80;                                                                   
  listen [::]:80;                                                              
  server_name somehost.com;                                      

   access_log /home/user1/appdir/log/access.log;                             
   error_log  /home/user1/appdir/log/error.log;                              
   location / {                                                                 

   # Proxy Headers                                                              
   proxy_set_header X-Real-Ip $remote_addr;                                    
   # proxy_set_header X-Cluster-Client-Ip $remote_addr;                         
   proxy_http_version 1.1;                                                     
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;                
   proxy_set_header Host $http_host;                                           


 # The Important Websocket Bits!                                             
 proxy_set_header Upgrade $http_upgrade;                                     
 proxy_set_header Connection $connection_upgrade;                            

 proxy_pass http://phoenix3;                                                 
 proxy_redirect off;                                                         

 }                                                                            
在apache中(获取真实世界的连接)


ServerName somehost.com
代理主机
代理请求关闭
ProxyPass/http://192.168.0.26/                                                 
ProxyPassReverse/http://192.168.0.26/

问题在于apache配置。 nginx配置正常,phoenix配置也正常

在apache虚拟主机中,需要添加

ProxyPass /socket/ ws://192.168.0.26/socket/                                     
ProxyPassReverse /socket/ ws://192.168.0.26/socket/     
在第一个块之前,然后添加一个附加的apache模块

a2enmod proxy_wstunnel
service apache2 restart  

你的凤凰港是什么?8765是标准,除非您更改它。它被更改为4020,正如在topI的nginx配置中提到的,我认为apache可能正在阻止websocket连接。我试图在没有nginx的情况下直接从apache连接到phoenix,但websocket仍然无法工作。那么可能是apache配置?问题是传入的ws://somehost.com调用被原始的proxy指令转换为http://somehost.com,并且还需要它来升级与proxy\u wstunnel的连接
a2enmod proxy_wstunnel
service apache2 restart