New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 765245 link

Starred by 41 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Feature


Show other hotlists

Hotlists containing this issue:
Hotlist-1
Hotlist-1


Sign in to add a comment

Using --proxy-pac-url in headless mode doesn't work.

Reported by jayhocke...@gmail.com, Sep 14 2017

Issue description

Chrome Version       : 61.0.3163.79
URLs (if applicable) : N/A
Other browsers tested: N/A

What steps will reproduce the problem?
(1) Create PAC file to block requests (all JavaScript files for example).
(2) Use ChromeDriver to run Chrome with the following options: --headless --disable-gpu --proxy-pac-url=<PAC file>

What is the expected result?
Headless Chrome should honor the --proxy-pac-url file and block requests.

What happens instead?
When I use ChromeDriver with --proxy-pac-url and no --headless, the expected requests in the PAC file are being blocked.
When I use ChromeDriver with --proxy-pac-url and --headless, the expected requests are not being blocked.
It appears that, when in headless mode, the --proxy-pac-url option is being ignored.

 
Cc: pnangunoori@chromium.org
Labels: Needs-Triage-M61 Needs-Feedback
@jayhockeyfan -- Thanks for reporting this issue. Could you please provide the sample PAC file. This would help us in further triaging the issue.

Could you also please provide the OS details to replicate the issue.

Thanks in advance.

Comment 2 by m...@louisroche.net, Sep 21 2017

I can confirm the same behavior for me using chrome headless through puppeteer.

My pac file:

```
https://bugs.chromium.org/p/chromium/issues/entry?components=Internals%3EHeadless&blocking=705916
```

This is how chromium is invoked in headless mode:

/home/louis/Code/test/v2/test_server/node_modules/puppeteer/.local-chromium/linux-499413/chrome-linux/chrome --disable-background-networking --disable-background-timer-throttling --disable-client-side-phishing-detection --disable-default-apps --disable-extensions --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-translate --enable-automation --enable-devtools-experiments --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=0 --safebrowsing-disable-auto-update --use-mock-keychain --user-data-dir=/tmp/puppeteer_dev_profile-LFIwKr --headless --disable-gpu --hide-scrollbars --mute-audio --disable-gpu --disable-setuid-sandbox --force-device-scale-factor --ignore-certificate-errors --no-sandbox --proxy-pac-url=file:///home/louis/Code/test/v2/test_server/built/proxy_pac.js

And in normal mode:

/home/louis/Code/test/v2/test_server/node_modules/puppeteer/.local-chromium/linux-499413/chrome-linux/chrome --disable-background-networking --disable-background-timer-throttling --disable-client-side-phishing-detection --disable-default-apps --disable-extensions --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-translate --enable-automation --enable-devtools-experiments --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=0 --safebrowsing-disable-auto-update --use-mock-keychain --user-data-dir=/tmp/puppeteer_dev_profile-9K3YUo --disable-gpu --disable-setuid-sandbox --force-device-scale-factor --ignore-certificate-errors --no-sandbox --proxy-pac-url=file:///home/louis/Code/test/v2/test_server/built/proxy_pac.js

Chromium revision: 499413
puppeteer: aa58f25bc1c7f8cf72c70c453f036bb873349164
Debian stretch

Comment 3 by m...@louisroche.net, Sep 21 2017

Looks like I failed to paste the pac file. Here it is:

"use strict";
function FindProxyForURL(_url, _host) {
    return `PROXY 127.0.0.1:10000;`;
}

The PAC file that I was playing around with:

function FindProxyForURL(url, host) {
  var url = url.toLowerCase();
  var host = host.toLowerCase();

  if (shExpMatch(url, "*.css")) { return "PROXY localhost:3421" }
  if (shExpMatch(url, "*.js")) { return "PROXY localhost:3421" }

  return "DIRECT";
}


I tried this on OS X version 10.11.5 and Debian Jessie.
Project Member

Comment 5 by sheriffbot@chromium.org, Sep 21 2017

Labels: -Needs-Feedback
Thank you for providing more feedback. Adding requester "pnangunoori@chromium.org" to the cc list and removing "Needs-Feedback" label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: dvallet@chromium.org
Components: Internals>Headless
Owner: rvera@chromium.org

Comment 7 by rvera@chromium.org, Oct 3 2017

Labels: -Needs-Triage-M61 Pri-3 Type-Feature
Owner: ----
Status: Available (was: Unconfirmed)
Headless does not implement all the possible proxy configurations, so this is a feature request rather than a bug.

We'll put it on our roadmap based on how many people want it, so star it if it's important to you.
Thanks for looking into it. It makes sense that this would be a feature request. I think this would a worthwhile feature to support in headless, since blocking certain requests that aren't needed would improve performance in multiple ways: reduce CPU usage, memory usage, and improve page load times.

Comment 9 by m...@louisroche.net, Oct 10 2017

Also, this is the only programmatic way to choose different proxies for different pages/resources without restarting chrome, which is a heavy action.
It would be really handy to have this feature. Then the support for the
most important proxy features is complete.

--proxy-server (61.0)
--proxy-bypass-list (62.0)
--proxy-pac-url (and hopefully 62.0)

I found myself in the middle of a testing suite with a proxy setup for
stubbing requests/responses. Unfortunately, I have to deal with WebSockets,
which I need to bypass. This is not possible with the bypass-list option,
and the following PAC config is not working on headless. (fine on non-headless)

function FindProxyForURL(url, host)
{
  if (url.substring(0, 3) == "ws:" ||
      url.substring(0, 4) == "wss:") {
    return "DIRECT";
  }

  return "PROXY localhost:39159";
}

It could be really useful also in other situations. Please add this to the roadmap. :)
i have use 65, and when i use the headless than the chrome do not requrest the pac file.

Up! 
I'd really appreciate if someone will work on this issue. It's really needed!
Thank you in advance.
Up!
I need this feature too.
I've implemented simple patch for kProxyPacUrl support according ChromeCommandLinePrefStore::ApplyProxyMode(). As manually tested, it works well for headless_shell and Chrome.app (with --headless in MacOS).
0001-Proxy-auto-config-switch-support-for-headless-mode.patch
2.9 KB Download
I tried your patch on a chromium fetch at 29/11/2018. Compile/Run on Linux Fedora 29 :
It doesn't work despite the config object is now well set, because headless mode seems to use a different proxy resolver than headfull :

From net/proxy_resolution/proxy_resolution_service.cc / ProxyResolutionService::CreateUsingSystemProxyResolver :
"PAC support disabled because there is no system implementation"

Note : I had a false hope when first trying, because "mandatory" was set to false in your patch, and chromium had fallback gracefuly by not using the PAC URL.

Sign in to add a comment