我正在尝试将Windows上的Apache websocket迁移到Ubuntu上的Nginx websocket。
适用于商业浏览器(Chrome,Firefox),但我在移动应用上报告错误:
Failed websocket opening handshake was canceled
我正在搜索很多错误,但我确信这是一般错误,而非特定错误。
Nginx配置(适用于不在手机上的浏览器)
server
{
listen 443 ssl;
server_name ws.example.com;
root /var/www;
ssl on;
ssl_verify_client off;
ssl_certificate /etc/nginx/ssl/cert.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_prefer_server_ciphers on;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA;
access_log /var/log/wss-access-ssl1.log;
error_log /var/log/wss-error-ssl1.log;
location /websocket
{
access_log off;
proxy_pass http://localhost:1234;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 86400; # neccessary to avoid websocket timeout disconnect
proxy_redirect off;
satisfy any;
}
}
Apache配置(适用于移动设备和浏览器)
<VirtualHost *:443>
ServerAdmin email@email.es
DocumentRoot "c:/Apache/htdocs"
ServerName ws.example.com
SSLEngine on
SSLProtocol All -SSLv2 -SSLv3
SSLCertificateFile "c:/Apache/apache/conf/ssl/__cert_com.crt"
SSLCertificateKeyFile "c:/Apache/apache/conf/ssl/server.key"
SSLCertificateChainFile "c:/Apache/apache/conf/ssl/__cert_com.ca-bundle"
Header set Access-Control-Allow-Origin "*"
<Directory "c:/Apache/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Deny,Allow
Allow from all
Require all granted
</Directory>
在Apache配置中,我添加了Header set Access-Control-Allow-Origin "*"
我在Nginx上尝试了它,但它没有用。
有什么建议吗?