how to run different node app on server different domains
var http = require('http'),
httpProxy = require('http-proxy');
var proxy_web = new httpProxy.createProxyServer({
target: {
host: 'localhost',
port: 8080
}
});
var proxy_api = new httpProxy.createProxyServer({
target: {
host: 'localhost',
port: 8081
}
});
http.createServer(function(req, res) {
if (req.headers.host === 'http://www.domain.com') {
proxy_web.proxyRequest(req, res);
proxy_web.on('error', function(err, req, res) {
if (err) console.log(err);
res.writeHead(500);
res.end('Oops, something went very wrong...');
});
} else if (req.headers.host === 'http://api.domain.com') {
proxy_api.proxyRequest(req, res);
proxy_api.on('error', function(err, req, res) {
if (err) console.log(err);
res.writeHead(500);
res.end('Oops, something went very wrong...');
});
}
}).listen(80);
Also in JavaScript:
- react js materilize
- react native map repeate
- declare array in javascript
- node_modules/react-native-paper/lib/module/core/Provider.js
- get multiple checkbox value in javascript
- find least common multiple javascript
- how to create a server in node js
- airbnb react native eslint
- json decode android
- jquery select input value empty and hasclass
- prepend option on 2nd index jquery
- javascript Count the occurrences of a value in an array
- js string template decimals
- warning Non-interactive elements should not be assigned mouse or keyboard event listeners jsx-a11y/no-noninteractive-element-interactions
- how to make a vowel counter in javascript
- jquery get the parent node
- react three fiber
- js new array from new set
- vue js cdn
- javascript 2 decimal float array elements
- Detect the city on application launch via geolocation react native
- install vue-cli
- js + random number in range without math.floor
- jquery dialog button text set by variable