alibaba / anyproxy

A fully configurable http/https proxy in NodeJS
http://anyproxy.io
Apache License 2.0
7.84k stars 1.22k forks source link

Is it possible to set a proxy for anyproxy ? #526

Open 24js opened 4 years ago

24js commented 4 years ago

Is it possible to set a proxy for anyproxy to tunnel traffic through that ?

Client ====> AnyProxy ===> Another HTTP/HTTPS Proxy ====> Internet

ljluestc commented 3 months ago
const AnyProxy = require('anyproxy');

const proxyHost = 'YOUR_PROXY_HOST'; // Replace with your proxy host
const proxyPort = YOUR_PROXY_PORT; // Replace with your proxy port

const options = {
  port: 8001, // AnyProxy listening port
  rule: null, // Optional: You can define your own rule if needed
  webInterface: {
    enable: false, // Disable the web interface to avoid conflicts
  },
  forceProxyHttps: true, // Force HTTPS proxy
  silent: false, // Set to true to suppress console output
  // Define the reverse proxy
  webProxy: {
    port: proxyPort,
    hostname: proxyHost,
    // Set to true if the proxy requires authentication
    // auth: 'username:password', // Uncomment and replace with your credentials if needed
  },
};

// Create the AnyProxy instance
const proxyServer = new AnyProxy.ProxyServer(options);

// Start the proxy server
proxyServer.on('ready', () => {
  console.log('AnyProxy reverse proxy is ready');
});

proxyServer.on('error', (e) => {
  console.error('AnyProxy encountered an error:', e);
});

proxyServer.start();