A simple HTTP proxy running in Node.js within a Docker container.
[
{
"target": "https://google.com",
"changeOrigin": true,
"pathFilter": "/google**",
"followRedirects": true,
"prependPath": true,
"ignorePath": true
}
]
See all the supported options in http-proxy-middleware.
$ npm run docker:run
$ curl -i http://localhost/google
You can use http-proxy-middleware
's advanced options creating more middlewares in index.js
:
// ## ADD YOUR CUSTOM PROXIES HERE ##
app.use(
'/api',
createProxyMiddleware({
target: 'http://www.example.org/api',
changeOrigin: true,
pathFilter: '/api/proxy-only-this-path',
pathRewrite: function (path, req) { return path.replace('/api', '/base/api') }
})
);
$ npm run dev