1. node express 테스트 예제
var express = require('express');
var app = express();
var expressWs = require('express-ws')(app);
app.get('/', function (req, res) {
res.send('Nginx demo!!!');
});
app.ws('/echo', function(ws, req) {
ws.on('message', function(msg) {
ws.send(msg);
});
});
app.listen(3000);
2. nginx 설정
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/express-access.log combined;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
'오픈소스 > nginx' 카테고리의 다른 글
nginx for beego (0) | 2018.02.02 |
---|---|
nginx for http2 (0) | 2018.02.02 |
nginx ssl 설정 (0) | 2018.02.02 |
nginx for flask (0) | 2018.02.02 |
nginx for django (0) | 2018.01.29 |