Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proxy server workaround for Contabo Server issue #1317

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,44 @@ Tests are written with [mocha](https://mochajs.org)
```bash
npm test
```

## Proxy Server Workaround

If you encounter the 'Sign in to confirm you’re not a bot' error on Contabo Server, you can use a proxy server to route requests through a different IP address, avoiding the blocked cloud provider IPs.

### Configuring the Proxy Server

1. Update the proxy URL to a working proxy server in `example/proxy.js`.
2. Add comments explaining how to configure the proxy server.

Example:

```js
const ytdl = require('..');
const HttpsProxyAgent = require('https-proxy-agent');

// Update the proxy URL to a working proxy server
const proxy = 'http://user:pass@proxyserver.example.com:8080';
const agent = HttpsProxyAgent(proxy);

// Configure the proxy server
// Remove 'user:pass@' if you don't need to authenticate to your proxy.

const stream = ytdl('https://www.youtube.com/watch?v=aqz-KE-bpKQ', {
requestOptions: { agent },
});

console.log('Starting Download');

stream.on('data', chunk => {
console.log('downloaded', chunk.length);
});

stream.on('error', err => {
console.error(err);
});

stream.on('end', () => {
console.log('Finished');
});
```
7 changes: 5 additions & 2 deletions example/proxy.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const ytdl = require('..');
const HttpsProxyAgent = require('https-proxy-agent');

// Remove 'user:pass@' if you don't need to authenticate to your proxy.
const proxy = 'http://user:pass@111.111.111.111:8080';
// Update the proxy URL to a working proxy server
const proxy = 'http://user:pass@proxyserver.example.com:8080';
const agent = HttpsProxyAgent(proxy);

// Configure the proxy server
// Remove 'user:pass@' if you don't need to authenticate to your proxy.

const stream = ytdl('https://www.youtube.com/watch?v=aqz-KE-bpKQ', {
requestOptions: { agent },
});
Expand Down