会话
默认情况下,每次请求都会轮换到一个新的 IP。当您需要在多个请求中使用相同的 IP 时,请开启粘性会话。
发送请求时不带 sid 标志。每个请求使用不同的 IP。
curl -x customer-USERNAME-country-us:PASSWORD@p.shifter.io:443 \ https://ipinfo.io/json# 72.14.201.44
curl -x customer-USERNAME-country-us:PASSWORD@p.shifter.io:443 \ https://ipinfo.io/json# 98.207.12.9在用户名中添加 sid-<id>。id 可以是您选择的任意字符串;使用相同 id 的后续请求会返回相同的 IP,直到 TTL 到期或该 IP 在上游断开连接。ttl-<seconds> 是可选的,且仅在与 sid 一起使用时有效,它会覆盖默认生命周期(120 秒,最小值为 1)。面板的端点构建器默认值也是 120。
customer-USERNAME-country-us-sid-order42 # default 120s lifetimecustomer-USERNAME-country-us-sid-order42-ttl-600 # custom 10-minute lifetimecurl -x customer-USERNAME-sid-order42-ttl-600:PASSWORD@p.shifter.io:443 \ https://ipinfo.io/json# 72.14.201.44
curl -x customer-USERNAME-sid-order42-ttl-600:PASSWORD@p.shifter.io:443 \ https://ipinfo.io/json# 72.14.201.44 (same)选择会话 id
Section titled “选择会话 id”- 为每个工作流选择唯一的标识(
order-42、user-a7f3、checkout-2024-11-21-1)。 - 两个不同的运行如果同时使用相同的 id,会争用同一个粘性 IP,产生冲突。
- id 是任意的;Shifter 不会解析它。它仅用作缓存键。
- 在
ttl秒后,映射会失效,下一次请求会轮换到新的 IP(目标定位标志会被保留)。 - 如果底层的住宅 IP 提前断开连接,会话会提前结束,下一次请求会发生轮换。
与地理定位结合使用
Section titled “与地理定位结合使用”粘性会话会遵循您设置的其他标志。会话 id 会在您的过滤条件范围内锁定一个 IP:
customer-USERNAME-country-us-city-los_angeles-sid-scrape1 # default 120scustomer-USERNAME-country-us-city-los_angeles-sid-scrape1-ttl-300 # custom 5-min在 TTL 有效期内,所有使用相同 id 的请求都会保持在同一个洛杉矶 IP 上。