그래서 nodejs/socket.io에서 게임을 만들려고하고 있지만 역방향 프록시가있는 서버에 배포 할 때마다 작동하지 않습니다. 모든 것이 로컬에서 잘 작동하지만 리버스 프록시에서는 404 오류를 찾을 수 없습니다.Node.js socket.io는 Nginx 역 프록시와 함께 404를 찾을 수 없습니다.
├── app.js
├── client
│ ├── css
│ │ └── main.css
│ ├── fonts
│ ├── img
│ ├── index.html
│ ├── index.pug
│ └── js
│ └── main.js
├── package.json
내 app.js :
응용 프로그램 포트는 5000
디렉터리 구조입니다
var express = require('express');
var app = express();
var serv = require('http').Server(app);
app.get('/node',function(req, res){
res.sendFile(__dirname + '/client/index.html');
});
app.use('/client',express.static(__dirname + '/client'));
serv.listen(5000);
var SOCKET_LIST={};
var io = require('socket.io')(serv,{});
index.html을 :
var socket = io();
Img.player.src='client/img/player.png'; //I have more like this
의 Nginx :
내가 myIpAdress에 갈 때location ~ ^/(node|socket\.io) {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header Origin http://$host;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
sub_filter /node /;
}
그래서 socket.io 작품/노드/I는 index.html 파일을 얻을 내가 응용 프로그램에 로그인 할 수 있습니다 작동하지 않는 것은 외부 파일 'myIpAdress에 대한 링크가 있습니다 /node/client/img/player.png '는 404 오류를 표시합니다.
어떤 아이디어가 클라이언트 폴더에 어떤 아이디어입니까? 과 같이 다른 위치에 블록을 추가