1

I have a server running on port 5000 and users don’t have access to this port.

I started another node server on 4000 and want to read the http content (localhost:5000/test) (content has javascripts) and users should see it on the browser by accessing port localhost:4000/test

Something like http content forward not the URL forward.

Any examples? Thanks in advance

1
  • 1
    You could do this with NGINX with a config file and no programming. Commented Oct 31, 2018 at 0:10

1 Answer 1

2


For this problem, I would recommend using a proxy such as https://github.com/nodejitsu/node-http-proxy
The code that you would need to implement on your server on port 4000 should look something like this:

const http = require('http'),
    httpProxy = require('http-proxy');
//
// Create your proxy server and set the target in the options.
//
httpProxy.createProxyServer({target:'http://localhost:5000'}).listen(4000); 
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.