blob: 41908c04179c1a999a34f278e4a14f06b1fe2167 [file] [log] [blame]
Matteo Scandolof0446ed2017-08-08 13:05:24 -07001/*
2 * Copyright 2017-present Open Networking Foundation
Matteo Scandolof0446ed2017-08-08 13:05:24 -07003 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
Matteo Scandolof0446ed2017-08-08 13:05:24 -07006 * http://www.apache.org/licenses/LICENSE-2.0
Matteo Scandolof0446ed2017-08-08 13:05:24 -07007 * Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS,
9 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 * See the License for the specific language governing permissions and
11 * limitations under the License.
12 */
13
Matteo Scandoloc46a82d2017-03-24 18:37:18 -070014const httpProxy = require('http-proxy');
15
16const target = process.env.PROXY || '192.168.46.100';
17
Matteo Scandolo22f8e822017-09-28 16:35:20 -070018console.log(`proxy setup to: ${target}`);
19
20const proxy = httpProxy.createProxyServer({
21 target: `http://${target}`
Matteo Scandoloc46a82d2017-03-24 18:37:18 -070022});
23
Matteo Scandolo22f8e822017-09-28 16:35:20 -070024proxy.on('error', (error, req, res) => {
Matteo Scandoloc46a82d2017-03-24 18:37:18 -070025 res.writeHead(500, {
26 'Content-Type': 'text/plain'
27 });
28 console.error('[Proxy]', error);
29});
30
Matteo Scandolo22f8e822017-09-28 16:35:20 -070031module.exports = proxy;