2017-09-16 33 views
0

我有我的開發機器上工作得很好,但是當它被移動到我的nginx服務器是看到一個應用程序:帶nginx的socket.io-client - 用404的POST失敗!爲什麼?

0|app  | ::ffff:127.0.0.1 - POST /socket.io-client/?EIO=3&transport=polling&t=LwCov_4 HTTP/1.1 404 157 - 0.344 ms 
0|app  | POST /socket.io-client/?EIO=3&transport=polling&t=LwCov_4 404 0.344 ms - 157 
0|app  | ::ffff:127.0.0.1 - GET /socket.io-client/?EIO=3&transport=polling&t=LwCowC_ HTTP/1.1 200 - - 1.045 ms 
0|app  | GET /socket.io-client/?EIO=3&transport=polling&t=LwCowC_ 200 1.045 ms - - 

那裏都得到的成功,所有郵局的失敗,404

相關nginx的配置的一部分是:

location/{ 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header Host  $host; 
    proxy_pass https://localhost:9000; 
    proxy_http_version 1.1; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-NginX-Proxy true; 
    proxy_redirect https://xxxx.com:9000/ https://xxxx.com/; 
} 

location ~* \.io { 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host  $http_host; 
    proxy_set_header Connection "upgrade"; 

    proxy_pass https://localhost:9000; 
    proxy_redirect off; 

    proxy_http_version 1.1; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header X-NginX-Proxy true; 
} 

快遞件具有:

import { handleSocket } from './config/socketio'; 

let server = https.createServer(options, app); 

let socketio = socket_io(server, { 
    serveClient: localEnv.env !== 'production', 
    path: '/socket.io' 
}); 

server.listen(localEnv.port,() => { 
    log('Express server listening on %d, in %s mode', localEnv.port, app.get('env')); 
}); 

而且在運行時得到:

2017-09-16T17:07:18-0400 app.js:192(服務器)Express服務器監聽9000,在生產模式 ,一切工作除了404對插座.io POST的

+0

請張貼顯示404 –

+0

的原因的nginx日誌好的 - 謝謝...我會在問題末尾添加日誌....在幾個... – JoelParke

+0

NATURALLY,因爲我想旋轉所有我的日誌和生成一套乾淨的日誌,我重新啓動了服務器(在Digital Ocean上),現在404的所有問題都消失了。去搞清楚!!但好消息是,我找不到任何配置錯誤,因爲顯然有什麼不對。但感謝https://stackoverflow.com/users/2830850/tarun-lalwani看這個! – JoelParke

回答