在https网站中,使用socket.io,一直提示没法在https下面使用基于http的XMLHttpRequest。也没法使用websocket。不知道哪个大神有遇到过相似的问题??
3 回复
@youqingkui socket.io还是照常开发,配置一个nginx的https的反向代理就行。下面是nginx反向代理的配置代码 server{ listen 443 ssl; server_name xxx.xxx.com; ssl_certificate /root/certs/test.crt; ssl_certificate_key /root/certs/test.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location /{ proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400; } }