DEV Community

98IP Proxy
98IP Proxy

Posted on Fully Autonomous

Rotate Proxy Credentials Without Turning Rotation Into an Outage

Proxy credentials are often treated like a configuration value: replace the old secret, restart the workers, and move on.

That is exactly how a routine security task becomes a production incident.

A crawler, monitoring agent, or data-collection service rarely has one credential consumer. The secret may exist in a scheduler, container platform, local development profile, serverless job, browser worker, health check, and emergency runbook. Those consumers do not all reload at the same time. A safe rotation therefore needs overlap, observability, and a rollback boundary.

This guide describes a provider-neutral rollout for systems you own or are authorized to operate.

First, separate the credential from proxy policy

Treat these as different configuration objects:

  • gateway hostname and port;
  • authentication username or account identifier;
  • secret or token;
  • target country, region, or session parameters;
  • retry and timeout policy.

If all five values live in one opaque URL, a password change can accidentally change routing behavior too. Parse the connection configuration once, keep the secret in a secret manager, and inject only the current credential at runtime.

Never print the full proxy URL. A masked log such as http://user:***@gateway:port is still useful for identifying the gateway without turning logs into a credential store.

Use an overlap window

The safest model is two valid credentials for a short, controlled period:

  1. Create the new credential without revoking the old one.
  2. Deploy the new secret to a small canary group.
  3. Verify authentication, tunnel creation, TLS completion, DNS behavior, target-region accuracy, and session stability.
  4. Expand the rollout in stages.
  5. Confirm that no active workload is using the old credential.
  6. Revoke the old credential.

If your provider cannot support overlapping credentials, schedule a maintenance window or use a blue/green account pattern. Do not assume that a synchronized restart will be truly simultaneous across queues, autoscalers, and long-running jobs.

Make the client reloadable

A long-running worker should be able to obtain the current secret without a full application redeploy. The exact mechanism depends on your platform, but the design should have three properties:

  • the secret is read from a managed source;
  • workers can refresh it on a bounded interval or configuration event;
  • in-flight requests keep their original credential while new requests use the new one.

Avoid retrying an authentication failure forever. A 407 Proxy Authentication Required after rotation is usually a configuration signal, not evidence that you need another exit IP.

Here is a language-neutral decision model:

if response == 407:
    refresh_secret_once()
    retry_once_with_same_route()
    if response == 407:
        open_rotation_circuit()
        alert("credential rejected")
Enter fullscreen mode Exit fullscreen mode

The same route matters. Rotating the exit at the same time changes two variables and makes diagnosis harder.

Canary on more than status code

A successful TCP connection is not enough. For each canary, record:

  • secret version identifier, never the secret value;
  • worker release and configuration revision;
  • gateway and requested region;
  • proxy authentication result;
  • CONNECT or SOCKS handshake result;
  • DNS mode and negotiated IP family;
  • TLS result;
  • exit geography and ASN, when that is part of the contract;
  • request latency and application result.

Compare the new credential with a known-good control under the same workload. A sudden increase in 407 responses points toward distribution or activation problems. Normal authentication with changed geography points toward a routing configuration change. Normal routing with application rejection points farther downstream.

Roll out in bounded stages

A practical sequence is 1%, 10%, 50%, and 100% of workers. Hold each stage long enough to observe at least one normal job cycle.

Define stop conditions before deployment. Examples:

  • more than 0.5% proxy-authentication failures;
  • any region mismatch for a regulated workflow;
  • p95 tunnel latency increasing by more than 20%;
  • workers continuing to request the retired secret version;
  • queue growth beyond the normal retry budget.

When a stop condition triggers, pause expansion. Do not compensate with unlimited retries: that can amplify load and hide the actual distribution failure.

Prove the old credential is unused

Revocation should be based on evidence, not elapsed time alone. Check:

  • secret-manager access logs by version;
  • active worker configuration versions;
  • scheduled and paused jobs;
  • disaster-recovery environments;
  • local or CI profiles that can reach production;
  • health checks and synthetic monitors.

Then run a negative test from an isolated, authorized environment: the old credential should fail, while the new credential should succeed. Do not place either secret in a ticket, chat transcript, screenshot, or HAR file.

Rotation checklist

  • [ ] Inventory every credential consumer.
  • [ ] Separate authentication from routing policy.
  • [ ] Create a new secret version and record its owner and expiry.
  • [ ] Confirm an overlap or maintenance strategy.
  • [ ] Canary with the same route and workload.
  • [ ] Monitor authentication, routing, latency, and application signals separately.
  • [ ] Roll out in bounded stages with written stop conditions.
  • [ ] Verify that the old version has no readers.
  • [ ] Revoke the old credential and run a negative test.
  • [ ] Remove temporary access and shorten retained diagnostic data.

The operational principle

Credential rotation is successful only when the new secret is accepted, the intended proxy route remains correct, every consumer has migrated, and the old secret is demonstrably unusable.

That makes rotation a small deployment—not a string replacement.

Disclosure: I work with 98IP. This article reflects an operator perspective and does not promise that credentials can override a destination's access policies. Use proxy infrastructure only for systems and data you are authorized to access. More English proxy engineering resources are available at https://en.98ip.com/?k=dev.

Top comments (0)