首页 > 其他 > 详细

NODE代理,yang

时间:2019-11-12 10:42:05      阅读:50      评论:0      收藏:0      [点我收藏+]
const express = require(‘express‘);
const proxy = require(‘http-proxy-middleware‘);//引入代理中间件
const app = express();
app.use(express.static(‘webapp‘));

// 测试
const host = ‘http://192.168.0.232:8382‘;//192.168.0.232:8382/

// 本地
// const host = ‘http://localhost:8091/‘;
// const host = ‘http://192.168.6.108:80/‘;

// Add middleware for http proxying
//将服务器代理
const appProxy = proxy(
    ‘/app/‘, {
        target: host,
        changeOrigin: true,
        pathRewrite: {
            ‘^/‘: ‘/‘
        }
    });
const drawProxy= proxy(
    ‘/draw/‘, {
        target: ‘http://120.24.168.179:8081‘,
        changeOrigin: true,
        pathRewrite: {
            ‘^/‘: ‘/‘
        }
    });
const gatewayProxy= proxy(
    ‘/gateway/‘, {
        // target: ‘http://119.23.175.96:6001‘,
        target: ‘http://192.168.0.238:6001‘,
        changeOrigin: true,
        pathRewrite: {
            ‘^/gateway‘: ‘/‘
        }
    });
const thirdPartyProxy= proxy(
    ‘/third-party/‘, {
        target: ‘http://192.168.0.242:8050‘,
        // target: ‘http://m.ibaboss.com/‘,
        changeOrigin: true,
        pathRewrite: {
            ‘^/‘: ‘/‘
        }
    });
app.use(‘/app/*‘, appProxy);//洋老板代理
app.use(‘/draw/*‘, drawProxy);//营销系统代理
app.use(‘/gateway/*‘, gatewayProxy);//秒杀代理
app.use(‘/third-party/*‘, thirdPartyProxy);//代理

// Render your site
app.get(‘/index.htm‘, function (req, res) {
    res.sendFile(__dirname + ‘/src/index.html‘);
});

app.listen(8099, () => {
    console.log(‘Listening on: http://localhost:8083‘);
});

NODE代理,yang

原文:https://www.cnblogs.com/ilovexiaoming/p/11840179.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!