我有這個錯誤請求。nginx as webserver incl。 socket.io和node.js/ws:// 400錯誤請求
在德國手段的最後一句「火狐無法連接到位於WS服務器:// ......」。
服務器不會是我想的問題。
因爲這裏是nginx配置,因爲我覺得有問題!
server {
server_name example.org;
listen 80 default_server;
root /var/www/web;
location/# for symfony2
{
try_files $uri @rewriteapp;
}
location @rewriteapp # for symfony2
{
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/app\.php(/|$)
{
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param HTTPS off;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ ^/socket
{
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
}
nginx的版本:nginx的/ 1.4.7
app.js
var express = require('express'),
io = require('socket.io').listen(server),
server = require('http').createServer(app),
bodyParser = require('body-parser');
var app = express();
server.listen(8080);
app.use(bodyParser.json());
app.post('/', function(request, response)
{
response.send('OK');
io.emit('MessageForAll', request.body);
});
io.on('connection', function (socket){});
console.log('Server running on port 8080.');
xhr民意測驗工程,我認爲。看看上面的截圖。問題是,ws://不起作用。如果使用xhr輪詢的系統可以使用ajax請求到後臺服務器,而不是使用額外的服務器。但謝謝你的回答。 – PatrickB 2014-09-02 07:45:34
@PatrickB我已更改答案。已在谷歌瀏覽器版本37.0.2062.94(64位)和Mozilla Firefox版本32.0上進行了測試。 – 2014-09-03 10:06:36
Wtf ...它不適用於我:(我不知道爲什麼服務器不發送101切換協議... – PatrickB 2014-09-08 10:10:33