0

I have in my private network different services, these services are not accessible from the out side (externe).

I'd like that my services be accessible to some users, and this after an authentication process (for this part I use express).

Once the user is authentificared it will be proxiate to the right service, I tried for this the http-proxy module.

enter image description here

Problem: I failed to use correctly http-proxy with express module, and resolve this enigma as wished.

Code: I began by doing this

    // Create app with Express
    var express  = require('express');
    var app      = express();

    // Create a proxy server with http-proxy
    var httpProxy = require('http-proxy');
    var proxy = httpProxy.createProxyServer();

    // Create target params (in the local network)
    var serverOne = {target:'ws://172.17.0.3:80',ws:true};

    // The use of proxy to expose the service
    app.all("/app/", function(req, res) {
        console.log('redirecting to Server1');
        proxy.web(req, res, serverOne);
    })

    // The login part
    .get('/login', function(req, res) {
        res.render('login.ejs');
        console.log('Cherche Login');
    })

    app.listen(8080);

Result:

enter image description here

Can someone help me please to fix this?

1 Answer 1

1

Try changing var serverOne = {target:'ws://172.17.0.3:80',ws:true};

to var serverOne = {target:'ws://172.1.0.3:80',ws:true};

Also check that from the server 104.155.15.204, you are able to access the 172.0.1.x network

You can have a look at http://expressjs.com/fr/api.html for implementation of proxies on express.

Regards,

Marc

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.