Simple Proxy Server with NodeJs

node.js, proxy

Solution

I got it working with a simple express application as you can see below:

var express = require('express');
var request = require('request');

var app = express();


app.use('/ext/', function(req, res) {

    var url = 'https://ext.a-nice-url.at/' + req.url;
    var options = {
        url: url,
        rejectUnauthorized: false
    }
    req.pipe(request(url)).pipe(res);
});

Problem

Currently I have got a simple proxy set up with Apache: ``` ProxyPass /ext/ https://ext.a-nice-url.at/ ProxyPassReverse /ext/ https://ext.a-nice-url.at ``` It is working fine, but in order to make it easier for others to install I was thinking to make a little server in nodejs. This Server will just be used for developers and testers, so it must not be very huge. I was already searching on google a bit and found http-proxy, but I am not sure how to use that properly. Any suggestions how I can make that?

Original source