Opt-In Software Blog

Software, dvelopment, and practical insights

Using Git SSH Through a SOCKS5 Proxy on Windows

Read in: English | Русский

Sometimes git push or git fetch over SSH may fail due to network restrictions or DPI filtering. Using a VPN solves the problem, but routing all system traffic through a VPN is not always desirable.

If your network connection is affected by DPI filtering, you can route Git SSH connections through a SOCKS5 proxy that bypasses these restrictions. The proxy can be running locally or on a remote server. OpenSSH’s ProxyCommand feature makes it possible to use this proxy without routing all system traffic through a VPN.

Configuration

Git for Windows already includes a utility called connect.exe, located at:

C:\Program Files\Git\mingw64\bin\connect.exe

Open the SSH configuration file (%USERPROFILE%\.ssh\config) and add:

Host github.com
    ProxyCommand "C:/Program Files/Git/mingw64/bin/connect.exe" -S 127.0.0.1:1080 %h %p

Here, github.com is just an example of an SSH server whose access is restricted. Replace it with the hostname you need. For example, it could be a Git server used by a particular project.

Replace 127.0.0.1:1080 with the address and port of your SOCKS5 proxy if necessary.

Note: On Windows, use forward slashes (/) in the executable path and specify the full path to connect.exe. Otherwise, OpenSSH may fail to locate the executable.

Testing

Test the SSH connection:

ssh -T git@github.com

Replace github.com with the hostname of your SSH server and git with your username.

If authentication succeeds, Git operations using SSH, including git push and git fetch, will use the SOCKS5 proxy.

This approach requires no system-wide VPN or changes to Windows network settings. Only SSH connections to the specified host are routed through the proxy.

Fixing Windows 11 Event ID 217 (Client.CBS) Log Spam

Read in: English | Русский

Symptoms

After booting Windows 11 (Build 26100), persistent background I/O and CPU load occurs, accompanied by elevated cooling fan speeds while the system is idle.

Diagnostics

  1. Disk Activity Analysis (resmon.exe): The Disk tab shows continuous, high-volume write operations targeting the following system event log file:
    C:\Windows\System32\winevt\Logs\Microsoft-Windows-AppModel-Runtime%4Admin.evtx
  2. Event Log Analysis (eventvwr.msc): Navigating to Applications and Services Logs → Microsoft → Windows → AppModel-Runtime → Admin reveals a continuous flood of Event ID 217 entries (dozens per second) with the following description:
Destroyed Desktop AppX container {GUID} for package MicrosoftWindows.Client.CBS_1000.26100.385.0_x64__cw5n1h2txyewy.

Root Cause

The MicrosoftWindows.Client.CBS (Client Experience Host) system package handles core Windows 11 shell components (Start menu, Taskbar, Notification Center, Widgets). Due to cache corruption or an improperly applied background update, one of the isolated processes (containers) within this package enters a continuous crash loop. Each time the container terminates, Windows logs an entry to AppModel-Runtime, generating constant disk and CPU overhead.

Resolution

To break the crash loop, force a re-registration of the affected AppX package manifest:

  1. Open PowerShell or Windows Terminal as Administrator.
  2. Execute the following command:
    Get-AppxPackage -AllUsers MicrosoftWindows.Client.CBS | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
    Note: Console errors indicating that package files are currently in use by active processes are expected and can be safely ignored.
  3. Restart the operating system.

Outcome

Following the reboot, the flood of Event ID 217 logs ceases, background writes to Microsoft-Windows-AppModel-Runtime%4Admin.evtx stop, and both CPU utilization and fan speeds return to normal idle levels.

NVIDIA Driver Bug: Excessive Writes to nvlog.nvlgstg

Read in: English | Русский

NVIDIA Driver Version

Some users have reported a problem with NVIDIA driver version 621.14 that causes background NVIDIA processes to repeatedly overwrite the nvlog.nvlgstg file.

The file is used by NVIDIA software for logging. Due to the bug, the NVDisplay.Container.exe process may generate excessive disk write activity, even when the computer is idle. This can result in unnecessary writes to the SSD and increased storage wear.

How to Check for the Problem

Windows includes a built-in tool that makes it easy to check whether this is happening: Resource Monitor.

  1. Press Win + R, type resmon, and press Enter.
  2. Open the Disk tab.
  3. Find NVDisplay.Container.exe in the Processes with Disk Activity section.
  4. In the Disk Activity section below, look for the nvlog.nvlgstg file.
  5. Observe the activity for a few minutes, preferably while the computer is otherwise idle.

If NVDisplay.Container.exe repeatedly writes to nvlog.nvlgstg, especially at a high rate, your system may be affected by this bug.

What to Do If You Find the Problem

Check NVIDIA’s driver release notes for a version containing the relevant fix and update your graphics driver. After updating, repeat the Resource Monitor check to make sure the excessive writes have stopped.

References

ProxyMapService: Editing HTTP Headers with RequestHeaders / ResponseHeaders Rules

Read in: English | Русский

Besides redirecting traffic, blocking hosts and decrypting SSL, ProxyMapService can edit HTTP headers on the fly. Two kinds of rules are available: RequestHeaders — add or replace headers sent to the upstream server (for example, to inject an Authorization header for upstream authentication that the client software does not support), and ResponseHeaders — edit headers sent back to the client (for example, to strip Server or X-Powered-By).

The rules work for plain HTTP and, when SSL decryption is enabled, for HTTPS too — including HTTP/2 traffic on both sides. The client and the server keep speaking their own protocols; the proxy quietly adjusts the headers in between.

What you can do with it

A few real-world use cases:

  • Upstream authentication — inject "Authorization": "Bearer ${API_TOKEN}" for a specific host whose API requires a token the client does not send. The token lives in an environment variable, not in the config file.
  • Traffic tagging — add an X-Gateway: ProxyMapService header to every request so the upstream can tell proxy traffic apart.
  • Cleanup — remove Server, X-Powered-By, tracking Cookies or any other headers from responses before they reach the client.
  • Proxy authentication — add or strip Proxy-Authorization for the next hop.

Configuration: three levels, merged

A rule has two properties: Set (a name → value map: replace every existing header with the same name and append the new value) and Remove (a list of header names to delete). Names are compared case-insensitively in both.

The rules are configured at three levels, and the levels are merged:

  • global — the HTTP section (HTTP:RequestHeaders / HTTP:ResponseHeaders);
  • Listen — inside a ProxyMappings entry, applies to all traffic of that listening port range;
  • HostRule — inside the HostRules section, applies only to the matching host (applied when the rule matches and its action is not Deny).

Precedence: global → Listen → HostRule. When merging, Set is merged by key — a higher level replaces the values of the same keys and adds new ones — and the Remove lists are combined. This makes it convenient to define a broad “baseline” globally and add host-specific rules on top.

Example — global rules plus a per-host Authorization injection:

"ProxyMappings": [
	{
		"Listen": {
			"Port": 5001,
			"DecryptSSL": true
		}
	}
],
"HTTP": {
	"RequestHeaders": {
		"Set": {
			"X-Gateway": "ProxyMapService"
		},
		"Remove": [
			"Proxy-Authorization"
		]
	},
	"ResponseHeaders": {
		"Remove": [
			"Server",
			"X-Powered-By"
		]
	}
},
"HostRules": {
	"Items": [
		{
			"HostName": "api.example.com",
			"RequestHeaders": {
				"Set": {
					"Authorization": "Bearer ${API_TOKEN}"
				},
				"Remove": [
					"Cookie"
				]
			}
		}
	]
}

With this configuration every request gets X-Gateway and loses Proxy-Authorization; every response loses Server and X-Powered-By; and requests to api.example.com additionally get an Authorization: Bearer ... header and lose their Cookie headers.

${VARIABLE} placeholders

Set values support ${VARIABLE} placeholders substituted with environment variables:

"Authorization": "Bearer ${API_TOKEN}"

The details that matter:

  • a missing variable is substituted with an empty string, and the whole resolved value is trimmed — so "Bearer ${UNSET}" becomes Bearer, not Bearer with a trailing space;
  • several placeholders can be used in one value: "${USER}-${REGION}";
  • CR/LF characters are stripped from the resolved value. This is a deliberate protection against header injection: even if an environment variable somehow contains a newline, it cannot smuggle an extra header into the request.

Keeping secrets in environment variables instead of the JSON config also means the same appsettings.Production.json can be committed or shared, while the actual tokens stay in the environment of the service.

What is never touched

Two kinds of headers are off-limits on purpose:

  • HTTP/2 pseudo-headers (:method, :path, :authority, :status, …). Even if a rule names one in Set or Remove, it is ignored — these headers define the request line and the target host, and rewriting them is the job of the dedicated Host override mechanism, not of header rules.
  • Transport framing headers (Content-Length, Transfer-Encoding) must not be modified: the proxy tracks the body length through these headers, and breaking them would corrupt the body tracking.

Where it works

Scenario Request headers Response headers
HTTP/1.1 client → HTTP/1.1 server ✅ ✅
HTTP/1.1 client → HTTP/2 server (translation) ✅ ✅
HTTP/2 client → HTTP/2 server ✅ not yet (forwarded as is)
Responses served from the cache — ✅
TLS passthrough (no decryption) — —

Notes:

  • For HTTPS, SSL decryption must be enabled — otherwise the proxy sees only encrypted bytes and there is nothing to edit. The rules ride on the same DecryptSSL: true switch as the rest of the traffic inspection.
  • In transparent h2 → h2 sessions response header rules are not applied yet. If response editing is required for such a host, use the h1 → h2 translation (an HTTP/1.1 upstream) — request rules work everywhere.
  • The same rules also apply to responses served by the proxy itself from the cache.

Under the hood: HTTP/2 header rewriting

Editing HTTP/2 headers is a different beast from HTTP/1.1, where a header block is just a list of lines. In HTTP/2 the headers are an HPACK-encoded block that can be split across HEADERS and CONTINUATION frames, and both sides keep a dynamic table of previously seen headers — a later frame may reference a header by index instead of sending it again.

The proxy handles this with a streaming rewriter that sits in the h2 → h2 path:

  • continuation blocks are reassembled — a header block split across HEADERS + CONTINUATION frames is decoded as one block and, if it does not fit into one frame (the payload limit is 16 384 bytes), split back into HEADERS + CONTINUATION on the way out;
  • the client’s dynamic table state is kept — frames that reference previously seen headers by index decode correctly, even though the proxy never forwards those index references;
  • re-encoded blocks contain only non-indexing literals — the proxy never emits indexed representations or dynamic table size updates towards the server, so its own encoding can never desynchronize the server’s table.

If something goes wrong at this level, the h2 connection is torn down rather than silently forwarding a corrupted stream.

Summary

RequestHeaders / ResponseHeaders is a small but complete mini-DSL inside the proxy configuration: two operations (Set, Remove), three configuration levels with predictable merging, environment-variable placeholders with injection protection, and consistent behavior across HTTP/1.1 and HTTP/2. Combined with HostRules it covers the typical “the client won’t send the header / the server shouldn’t see the header” scenarios without touching the client or the server.

ProxyMapService: TlsClientType Auto — Matching the TLS Fingerprint to the Client's User-Agent

Read in: English | Русский

In the previous posts I described how ProxyMapService can make its upstream TLS handshake look like a real browser: Chrome-like TLS fingerprinting came first, and then TlsClientType replaced the old UseBoringSsl flag with a choice between Native, BoringSsl and Nss.

There was one catch. TlsClientType is a fixed setting: you pick one fingerprint for a port or a host, and every connection gets it. But the traffic going through the proxy usually comes from different clients. If a request with a Firefox User-Agent arrives with a Chrome ClientHello, the mismatch is itself a signal. Version 1.0.12 solves this with a fourth value, Auto, which chooses the fingerprint for each session from the client’s User-Agent.

TlsClientType = Auto (1.0.12)

Why you might need it

A browser-like fingerprint is only useful when it matches what the client claims to be. With a static BoringSsl setting, a Firefox client is fingerprinted as Chrome. With a static Nss setting, it is the other way around. Auto removes the need to choose: the proxy looks at the User-Agent and picks the matching TLS implementation.

How to enable

"SslClientOptions": {
    "TlsClientType": "Auto"
}

Auto is resolved at the moment the upstream TLS handshake starts, using these rules:

User-Agent TLS implementation ClientHello
Firefox Nss Firefox-like
Chrome, Edge (Edg/), Opera (OPR/), Chromium BoringSsl Chrome-like
Anything else (Safari, curl, bots) Native system SslStream

Edge and Opera are Chromium-based, so they get the Chrome-like fingerprint. Everything the proxy does not recognize falls back to the system TLS stack, exactly as before.

As with BoringSsl and Nss, Auto produces a browser-like fingerprint only when SSL decryption is enabled, because the proxy has to open its own upstream TLS connection. Without it, there is no ClientHello of the proxy’s own to shape.

Where the User-Agent comes from

The proxy uses the first User-Agent it can find, in this order:

  1. The client User-Agent stored in the sticky session.
  2. The User-Agent header of the incoming request. For HTTP proxying this is the CONNECT request.
  3. Nothing known: for example, a SOCKS connection without a sticky session. In this case the proxy falls back to Native.

The fingerprint is fixed when the upstream handshake completes. If the User-Agent changes later, the change affects only new connections, not the ones that are already established.

Client User-Agent in the Session API (1.0.12)

Sticky sessions now keep a client User-Agent, so the choice can be made even for connections that carry no User-Agent themselves, such as SOCKS.

You can set it explicitly when you create a session:

  • POST /session/new: add a top-level UserAgent key to the JSON body, next to UsernameParameters.
  • GET /session/new?UserAgent=...: pass it as a query parameter. It is not treated as a username parameter.

For example, with curl. The request goes through the proxy, and proxymapper is the default SessionAPIConfig.Domain. With a query parameter (-G --data-urlencode lets curl encode the User-Agent for the URL):

curl -x http://127.0.0.1:5001 -G "http://proxymapper/session/new" \
    --data-urlencode "UserAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"

Or with a POST body:

curl -x http://127.0.0.1:5001 -X POST "http://proxymapper/session/new" \
    -H "Content-Type: application/json" \
    -d '{"UserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0"}'

A session created by the first command gets the BoringSsl (Chrome-like) fingerprint, and one created by the second gets Nss (Firefox-like).

If you do not pass it, the User-Agent header of the Session API request itself is used. The current value is returned as user_agent in GET /session/.

Explicit and detected values

There are two kinds of values, and they behave differently:

  • Explicit. A User-Agent that you set through the Session API is never overwritten by detection. It can only be replaced by another explicit value, cleared by /session/reset, or dropped when the sticky session expires.
  • Detected. If you did not set one, every parsed HTTP request with a non-empty User-Agent updates the session value. This works for HTTP/1.1, HTTP/2, CONNECT and plain requests. A SOCKS connection that comes later in the same session inherits the detected value.

This means a typical flow needs no extra work. A browser sends a few HTTP requests through the proxy, the session learns its User-Agent, and any later connection in that session gets a matching fingerprint.

Logging (1.0.12)

A new switch, DetailedLogging:LogClientUserAgent, is off by default. When it is on, the log shows the TlsClientType that was resolved for each connection, and it warns whenever the proxy fell back to Native because no User-Agent was known:

"DetailedLogging": {
    "LogClientUserAgent": true
}

It is useful for checking that your clients are classified the way you expect.

Upgrading

The default configuration files (appsettings.json, appsettings.IIS.json and appsettings.Production-Example.json) now ship with "TlsClientType": "Auto" instead of "Native". Custom configurations keep their current values, so if you want Auto, set it yourself.

Two things to remember:

  • Auto needs SSL decryption, the same as BoringSsl and Nss.
  • Without a known User-Agent, it silently uses the system TLS stack. Turn on LogClientUserAgent if you want to see when that happens.

Search