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'; app.use('/', proxy(targetUrl, { https: true, proxyReqOptDecorator: (proxyReqOpts, srcReq) => { //console.log(srcReq); // Modify the request headers if necessary proxyReqOpts.headers['x-forwarded-for'] = '51.158.166.131'; 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=51.158.166.131;proto=https`; // Пример изменения User-Agent proxyReqOpts.headers['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'; // Пример изменения Referer proxyReqOpts.headers['referer'] = 'https://www.bing.com/images/create'; return proxyReqOpts; }, })); app.listen(port, () => { console.log(`Reverse proxy server running on ${baseUrl}`); });