scrapy-proxy-headers 0.2.2 hardens how the package handles proxy headers, and it requires Scrapy 2.17.0 or later, the release that patches a high-severity advisory. If you run Scrapy 2.17 through 2.19 on Python 3.8 or newer, upgrade from 0.2.1. Your settings and request meta don't need to change.
pip install -U 'scrapy-proxy-headers==0.2.2'
Security: CONNECT header handling
0.2.2 rejects a line break (CR or LF) in a proxy_headers name or value and
raises ValueError, so a header can't add extra lines to the request the
package sends to the proxy. It also reads the proxy's reply more carefully: a
header split across network packets stays intact, and bytes after the headers
aren't treated as headers.
When the package copies the proxy's headers onto the HTTPS response, it leaves
the website's headers unchanged. 0.2.1 replaces a website header such as
Content-Type or Set-Cookie when the proxy sends a header with the same
name. New proxy headers such as X-ProxyMesh-IP are still copied.
Security: Scrapy 2.17.0 is required
CVE-2026-84366 is a
high-severity advisory (CVSS 7.4) for Scrapy versions before 2.17.0.
Before 2.17.0, Scrapy's S3 download handler sends signed s3:// requests over
plaintext HTTP unless request.meta["is_secure"] is true, which exposes the
request path, the AWS Authorization header, and the response to a network
attacker. If you make
s3:// requests with AWS credentials, this affects you.
Scrapy 2.17.0
uses HTTPS by default. 0.2.2 requires scrapy>=2.17.0, so the upgrade command
above also upgrades Scrapy when the environment has an older version.
Requirements: Scrapy 2.17 to 2.19, Python 3.8+
0.2.2 requires Scrapy 2.17.0 up to, but not including, 2.20, and Python 3.8 or newer. It doesn't install or run on Scrapy 2.20, which adds built-in proxy headers support. Install scrapy-proxy-headers 0.3.0 for Scrapy 2.20, or if you run Python 3.10 or newer.
Example: choose a country and read the proxy IP
import scrapy
class CountrySpider(scrapy.Spider):
name = "country"
custom_settings = {
"DOWNLOAD_HANDLERS": {
"https": "scrapy_proxy_headers.HTTP11ProxyDownloadHandler",
},
}
async def start(self):
yield scrapy.Request(
"https://api.ipify.org?format=json",
meta={
# X-ProxyMesh-Country works on the World and Open proxies.
"proxy": "http://USERNAME:PASSWORD@PROXY_HOST:PORT",
"proxy_headers": {"X-ProxyMesh-Country": "DE"},
},
)
def parse(self, response):
proxy_ip = response.headers.get(b"X-ProxyMesh-IP")
yield {"proxy_ip": proxy_ip.decode() if proxy_ip else None}
The request and response headers article lists every header ProxyMesh accepts and returns. The Python proxy configuration article covers the Scrapy setup.
Install it from scrapy-proxy-headers 0.2.2 on PyPI. The GitHub release notes and the full diff from 0.2.1 list the changes. Usage is covered in the scrapy-proxy-headers documentation.