const express = require('express'); const proxy = require('express-http-proxy'); const app = express(); const targetUrl = 'https://www.bing.com'; const port = 7860; const baseUrl = 'bing'; const IP = '148.113.165.150'; app.use('/', proxy(targetUrl, { https: true, proxyReqOptDecorator: (proxyReqOpts, srcReq) => { //console.log(srcReq); // Modify the request headers if necessary proxyReqOpts.headers['x-forwarded-for'] = IP; proxyReqOpts.headers['x-forwarded-proto'] = 'https'; proxyReqOpts.headers['x-forwarded-host'] = srcReq.headers['host']; proxyReqOpts.headers['via'] = '1.1 example-proxy'; proxyReqOpts.headers['forwarded'] = `for=${IP};proto=https`; proxyReqOpts.headers['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36'; proxyReqOpts.headers['referer'] = 'https://www.bing.com/images/create'; return proxyReqOpts; }, })); app.listen(port, () => { console.log(`Reverse proxy server running on ${baseUrl}`); });