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

how to set proxy auth ? #676

Closed
WG-Com opened this issue Sep 4, 2017 · 15 comments
Closed

how to set proxy auth ? #676

WG-Com opened this issue Sep 4, 2017 · 15 comments

Comments

@WG-Com
Copy link

WG-Com commented Sep 4, 2017

my proxy server has authentication

(async() => {
    const browser = await puppeteer.launch({
    args: [  '--proxy-server='+proxyServer+'','--no-sandbox', '--disable-setuid-sandbox' ]
});
const page = await browser.newPage();
await page.goto('https://www.google.com/');
await page.screenshot({path: 'full.png', fullPage: true});
browser.close();
@juanchristensen
Copy link

+1

1 similar comment
@pg1671
Copy link

pg1671 commented Sep 4, 2017

+1

@bogdan0083
Copy link

bogdan0083 commented Sep 5, 2017

+1. I still can't find a way to authenticate proxy using puppeteer. I tried to do auth like this:

const browser = await puppeteer.launch({
    args: ['--proxy-server=IP:LOGIN:PASSWORD']
});

but then chromium just crashes and nothing happens.

@aslushnikov
Copy link
Contributor

Dupe of #426

@WG-Com
Copy link
Author

WG-Com commented Sep 7, 2017

can you put it into example folder ? i add proxy-Auth.... header , not work , many people care about this question @aslushnikov

@tmpace
Copy link

tmpace commented Sep 15, 2017

+1

@androidfanatic
Copy link

Definitely +1.
Currently using a local CNTLM installation to avoid auth.

@aslushnikov
Copy link
Contributor

@androidfanatic @WG-Com @tmpace page.authenticate has landed in current alpha.

@adarmanto
Copy link

adarmanto commented Dec 14, 2017

Not sure, page.authenticate is not working for me, and I used page.setExtraHTTPHeaders to workaround:

const browser = await puppeteer.launch({
    ignoreHTTPSErrors: true, 
    args: ['--proxy-server=example.com:8080']
});
const page = await browser.newPage();
await page.setExtraHTTPHeaders({
    'Proxy-Authorization': 'Basic ' + Buffer.from('user:pass').toString('base64'),
});

@jancurn
Copy link

jancurn commented Jan 9, 2018

@adarmanto This will only work for HTTP websites, but not HTTPS. Here's a blog post describing a workaround - https://medium.com/@jancurn/how-to-make-headless-chrome-and-puppeteer-use-a-proxy-server-with-authentication-249a21a79212

@adarmanto
Copy link

@jancurn Awesome! But I forgot to mention about ignoreHTTPSErrors option to work with HTTPS for my solution above (edited).

@Robertzewen
Copy link

@adarmanto I added ignoreHTTPSErrors in args ,but also not work.

@Robertzewen
Copy link

@aslushnikov
const browser = await puppeteer.launch({
ignoreHTTPSErrors: true,
args: ['--proxy-server=example.com:8080']
});
const page = await browser.newPage();
//await page.authenticate({'username':username,'password':password});
await page.setExtraHTTPHeaders({
'Proxy-Authorization': 'Basic ' + Buffer.from('user:pass').toString('base64'),
});
This will only work for HTTP websites, but not HTTPS. What should I do?thanks

@greenorigin
Copy link

This actually works like a charm to me.

const browser = await puppeteer.launch({
args: [
'--proxy-server=YOUR-PROXY-SERVER:PORT'
],
});

After Pupperteer Launch use following parameters to authenticate.

await page.authenticate({
username: 'USER-NAME',
password: 'PASSWORD',
});

@ChenYCL
Copy link

ChenYCL commented Feb 1, 2022

global how to set?like page1,page2,page3..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests