I'm trying to set a reverse proxy in my Web-Api controller, so that I can filter the requests vía URI and send them to their respective destinataries.
So far I have a reverse proxy in Node.js + Express as following, that I'm trying to migrate to the WebApi controller:
var serverOne = 'http://localhost:8080/geoserver/TRAC/wms?';
var serverTwo = 'https://iden.com/ogc/wms?';
var serverThree = 'https://inspi.com/services/CP/wfs';
app.all('/geoserver', function (req, res) {
apiProxy.web(req, res, {target: serverOne});
});
app.all('/idena', function (req, res) {
apiProxy.web(req, res, {
changeOrigin: true,
target: serverTwo
});
});
app.all('/inspire', function (req, res) {
apiProxy.web(req, res, {
changeOrigin: true,
target: serverThree
});
});
So this is basically what I'm trying to achieve:
localhost:65000/geoserver
request, resend it to serverOne
localhost:65000/idena
request, resend it to serverTwo
localhost:65000/inspire
request, resend it to serverThree
I have been researching different methods as using a Handler or installing third part components, but I'm not sure that these are correct approaches.
Which techniques or technologies should I use to set a reverse proxy on my controller in ASP.NET Web API 2?
It is not possible directly in the WebAPI controller, but this can easily be done adding an ASP.NET handler to the project.
And then creating the reverse proxy as mentioned here