Skip to content

Conversation

@sadym-chromium
Copy link
Contributor

@sadym-chromium sadym-chromium commented Aug 29, 2025

Addressing #1920.

Currently, WebDriver capabilities allow for configuring proxy by protocol. Meaning the protocol traffic can be proxied via the same protocol proxy.

Chromium can proxy traffic via different proxy protocols, and can configure which proxy to use for which protocol. In Chromium, the possible proxy schemas are http, https, socks4, socks5. Also user can configure separately proxy for HTTP, HTTPS and all other requests (SOCKS).

In order to allow for such configurations, we propose the following:

  • Allow for schemas (http, https, socks, socks4, socks5) in the proxy url.

Here is the details list of options can be provided in the capabilities:

http proxy

The list of cases, when the proxy is connected with HTTP protocol:

  • (existing) httpProxy: proxy.com. The traffic type is used, as not scheme, nor port were set.
  • (existing) httpProxy: proxy.com:123. The traffic type is used, as scheme was not set, and the port is not standard for any supported proxy protocol.
  • (new) sslProxy: http://proxy.com. The scheme has priority over traffic type.
  • (new) socksProxy: http://proxy.com. The scheme has priority over traffic type. socksVersion is not required.
  • (new) sslProxy: http://proxy.com:443. The scheme has priority over port and traffic type.
  • (new) socksProxy: http://proxy.com:443. The scheme has priority over port and traffic type. socksVersion is not required.
  • (new) sslProxy: proxy.com:80. The port has priority over traffic type.
  • (new) socksProxy: proxy.com:80. The port has priority over traffic type. socksVersion is not required.

https proxy

The list of cases, when the proxy is connected with SSL protocol:

  • (existing) httpsProxy: proxy.com. The traffic type is used, as not scheme, nor port were set.
  • (existing) httpsProxy: proxy.com:123. The traffic type is used, as scheme was not set, and the port is not standard for any supported proxy protocol.
  • (new) httpProxy: https://proxy.com. The scheme has priority over traffic type.
  • (new) socksProxy: https://proxy.com. The scheme has priority over traffic type. socksVersion is not required.
  • (new) httpProxy: https://proxy.com:80. The scheme has priority over port and traffic type.
  • (new) socksProxy: https://proxy.com:80. The scheme has priority over port and traffic type. socksVersion is not required.
  • (new) httpProxy: proxy.com:443. The port has priority over traffic type.
  • (new) socksProxy: proxy.com:443. The port has priority over traffic type. socksVersion is not required.

socks proxy

The list of cases, when the proxy is connected with SOCKS protocol:

  • (existing) socksProxy: proxy.com + socksVersion: 4/5. The traffic type is used, as not scheme, nor port were set.
  • (existing) socksProxy: proxy.com:123 + socksVersion: 4/5. The traffic type is used, as scheme was not set, and the port is not standard for any supported proxy protocol.
  • (new) httpProxy: socks://proxy.com + socksVersion: 4/5. The scheme has priority over traffic type.
  • (new) httpProxy: socks4://proxy.com. The scheme has priority over traffic type. socksVersion is part of scheme.
  • (new) httpProxy: socks5://proxy.com. The scheme has priority over traffic type. socksVersion is part of scheme.
  • (new) sslProxy: socks://proxy.com + socksVersion: 4/5. The scheme has priority over traffic type.
  • (new) sslProxy: socks4://proxy.com. The scheme has priority over traffic type. socksVersion is part of scheme.
  • (new) sslProxy: socks5://proxy.com. The scheme has priority over traffic type. socksVersion is part of scheme.
  • (new) httpProxy: socks://proxy.com:80 + socksVersion: 4/5. The scheme has priority over port and traffic type.
  • (new) httpProxy: socks4://proxy.com:80. The scheme has priority over port and traffic type. socksVersion is part of scheme.
  • (new) httpProxy: socks5://proxy.com:80. The scheme has priority over port and traffic type. socksVersion is part of scheme.
  • (new) sslProxy: socks://proxy.com:80 + socksVersion: 4/5. The scheme has priority over port and traffic type.
  • (new) sslProxy: socks4://proxy.com:80. The scheme has priority over port and traffic type. socksVersion is part of scheme.
  • (new) sslProxy: socks5://proxy.com:80. The scheme has priority over port and traffic type. socksVersion is part of scheme.
  • (new) httpProxy: proxy.com:1080 + socksVersion: 4/5. The port has priority over traffic type.
  • (new) sslProxy: proxy.com:1080 + socksVersion: 4/5. The port has priority over traffic type.

Preview | Diff

@sadym-chromium sadym-chromium requested a review from OrKoN August 29, 2025 15:01
@sadym-chromium sadym-chromium changed the title Align "proxy" string configuration with Chromium implementation Allow for "proxy" schemas Aug 29, 2025
@sadym-chromium sadym-chromium changed the title Allow for "proxy" schemas Allow for specifying schema in "proxy" Aug 29, 2025
@sadym-chromium sadym-chromium marked this pull request as ready for review August 29, 2025 15:33
Copy link
Contributor

@OrKoN OrKoN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

</tr>

<tr>
<td><code>socksVersion</code>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you removed the socksVersion field? I thought that for socks proxies it is a mandatory field. Also if clients specify this field we would run into a backward incompatible change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key change is that the "socksProxy" field sets how to proxy ALL the socks connections, not only of the specific version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WRT backward compatibility, we can figure things out if we agree on what we want to achieve.

Copy link
Contributor Author

@sadym-chromium sadym-chromium Sep 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the Chromium perspective, the socksVersion does not make actually sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the socks version will cause a backward incompatible change, means it will break clients using that field. We probably should fine a way to deprecate if it is really not needed. But note that when defining a socks proxy in Firefox you need to specify the version. So I don't think that we can get rid of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I re-worked the PR so that the socksVersion can be used together with socks:// scheme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can default socksVersion to 5 to ease the API. @whimboo WDYT?

index.html Outdated
undefined.

<p>A <dfn>proxy schema</dfn> is defined as being one of the following strings:
"<code>http</code>", "<code>https</code>", "<code>socks4</code>",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither socks4 nor socks5 is a valid schema as supported by Firefox. For socks proxy there is usually no schema at all when specifying the host. Does Chrome support that? Also note the other comment above regarding the backward incompatible change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As documented here, Chrome supports proxy via HTTP, SSL, SOCKS 4 and SOCKS 5:

  • http://proxy:8080 uses HTTP.
  • https://proxy:8080 uses SSL.
  • socks4://proxy:8080 uses SOCKS 4.
  • socks5://proxy:8080 uses SOCKS 5.
  • socks://proxy:8080 uses SOCKS 5, as schema "socks" is alias for schema "socks5".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither socks4 nor socks5 is a valid schema as supported by Firefox. For socks proxy there is usually no schema at all when specifying the host. Does Chrome support that? Also note the other comment above regarding the backward incompatible change.

Does it mean that Firefox cannot proxy SOCKS 5 via SOCKS 4 and vice versa?

@sadym-chromium
Copy link
Contributor Author

@whimboo WDYT?

</tr>

<tr>
<td><code>socksVersion</code>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the socks version will cause a backward incompatible change, means it will break clients using that field. We probably should fine a way to deprecate if it is really not needed. But note that when defining a socks proxy in Firefox you need to specify the version. So I don't think that we can get rid of it.

index.html Outdated
Comment on lines 1659 to 1660
<var>scheme</var> is omitted, the <var>scheme</var> is implied to be
"<code>http</code>". If the port is omitted and <var>scheme</var> has a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we at least try to figure out the right scheme (if not given) in case a default port has been set for the proxy? Using host:443 should most likely be a HTTPS proxy, or? If the port is not given, I assume that we could fallback to HTTP (HTTPS proxies still seem to be used rarely).

Should we add a note to indicate any change to the former version of the spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a note to indicate any change to the former version of the spec?

Do you have an idea of proper wording?

@sadym-chromium
Copy link
Contributor Author

@whimboo WDYT?

@sadym-chromium
Copy link
Contributor Author

@whimboo could you please take another look?

Copy link
Contributor

@whimboo whimboo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking so long with my review. Inline you can find some comments so that we can continue the discussion.

<td>Defines the <a>SOCKS proxy</a> version
when the <a><code>proxyType</code></a> is "<code>manual</code>".
<td>Defines the <a>SOCKS proxy</a> version when the <a>proxy url</a>'s
<a>proxy scheme</a> is "<code>socks</code>".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my comment above. It would be a backward compatibility breaking change when we now introduce a socks scheme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated algorithm. The socksVersion is required, if any of the proxies has socks schema, or if the socksProxy don't have schema.

index.html Outdated

<li><p>If the <var>scheme</var> is omitted and the <var>port</var> is 443,
the <var>scheme</var> is implied to be "<code>https</code>". Otherwise, the
<var>scheme</var> is implied to be "<code>http</code>".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph should only apply to HTTP or HTTPS proxies but not for a proxy URL as specified for a socks proxy.


<p>A <dfn>proxy scheme</dfn> is defined as being one of the following strings:
"<code>http</code>", "<code>https</code>", "<code>socks</code>",
"<code>socks4</code>", "<code>socks5</code>".
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think that is a backward incompatible given that we didn't use a scheme for socks so far and I'm unsure how clients actually specify the socks proxy.

@jgraham maybe you have some additional feedback.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the algorithm.

  • Old users omitted schema in proxy url, and expected the traffic to be proxied to the same protocol.
  • Now, the schema defaults to the protocol to proxy. So this the behavior for them is not changed.

However, if the user WANTS to specify schema, now they can do it.

@css-meeting-bot
Copy link
Member

The Browser Testing and Tools Working Group just discussed Allow for specifying schema in "proxy".

The full IRC log of that discussion <AutomatedTester> topic: Allow for specifying schema in "proxy"
<AutomatedTester> github: https://github.com//pull/1922
<AutomatedTester> sadym: what is specified in the spec isn't what chromium does, chromium does a lot more
<AutomatedTester> ... I have reworked the proposal and it is backwards compatiable
<AutomatedTester> ... please look and consider this for merging
<AutomatedTester> q?

Comment on lines +1752 to +1753
<li><p>If <var>proxy</var> contains <a>proxy url</a> with <a>proxy scheme</a>
"<code>socks</code>" and does not have an <a>own property</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you recently replaced has an <a>own property</a> for "<code>socksProxy</code>"? For a socks proxy configuration we should only check the requirement for the socks versionwhen a socks proxy was actually specified. Also to what wouldproxy contains proxy url` point to? It's not a key but a value for some other possible proxy config - a http proxy with socks scheme should not be considered here, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extended the description of the issue with detailed list of possible capabilities. This line was changed in order to fulfill new scenarios under "socks proxy" section. Otherwise the socks version to be used to connect to the proxy would be undefined. E.g.

  • httpProxy: socks://proxy.com + socksVersion: 4/5.

If we restrict the scheme to socks, that would restrict all the traffic to be proxied via the same socks protocol version. So you wouldn't be able to proxy http traffic via socks5, while ssl traffic via sock4. Even though this seems quite niche scenario, such a restriction seems quite artificial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants