Skip to content
shouya edited this page Jul 8, 2024 · 3 revisions

Image Proxy

RSS Funnel provides an image proxy feature to circumvent limitations set by some websites that restrict image loading. This feature is implemented as a filter that can rewrite image URLs in your feeds.

Using the Image Proxy

The image proxy is configured and used through the image_proxy filter in your RSS Funnel configuration. In most cases, no configuration is needed, and you can use the built-in proxy right away.

Basic Configuration

To use the image proxy with default settings, simply add it to your filters:

filters:
  - image_proxy: {}  # Use default settings

Advanced Configuration Options

While the default settings work for most cases, you can customize the behavior if needed.

Proxy Settings

You can use either the built-in proxy or an external proxy service.

Built-in Proxy

The built-in proxy is ready to use without any additional configuration. However, you can customize its behavior if needed:

filters:
  - image_proxy:
      proxy: socks5://localhost:9150  # Optional
      referer: image_url_domain
      user_agent: "Custom User Agent String"
  • proxy (optional): Specify a proxy for the image request
  • referer (optional, default: image_url): The referer header for the image request
    • Options: none, image_url, image_url_domain, or a custom string
  • user_agent (optional, default: transparent): The user-agent header for the image request
    • Options: none, transparent, or a custom string
External Proxy

If you prefer to use an external proxy service:

filters:
  - image_proxy:
      external:
        base: "https://external-proxy.example.com/proxy?url="
        urlencode: true
  • base: The base URL of the external proxy service
  • urlencode (optional): Whether to URL-encode the image URLs before appending them to the base. The default value depends on the base URL:
    • If the base URL ends with "=", the default is true
    • Otherwise, the default is false

This default behavior is designed to work with common external proxy services:

  • Some services expect the URL to be the last parameter, like https://proxy.example.com/?url=, where URL encoding is typically needed.
  • Others might expect the URL to be appended directly, like https://proxy.example.com/, where encoding might interfere with their parsing.

By analyzing the base URL, the system tries to guess the appropriate default. You can always override this by explicitly setting urlencode to true or false.

Image Selection

You can specify which images the proxy should be applied to. This works for both built-in and external proxies:

filters:
  - image_proxy:
      domains:
        - "*.example.com"
        - "images.somesite.net"
      selector: "img.proxy-me"
  • domains (optional): A list of domains to which the proxy should be applied (supports globbing)
  • selector (optional, default: "img"): A CSS selector to match the <img> tags for URL rewriting

Example Configurations

Built-in Proxy with Custom Settings

filters:
  - image_proxy:
      referer: image_url_domain
      user_agent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
      domains:
        - "*.example.com"
      selector: "img.proxy-me"

External Proxy

filters:
  - image_proxy:
      external:
        base: "https://images.weserv.nl/?url="
        urlencode: true
      domains:
        - "*.exampleimages.com"

How It Works

This section describes how the image proxy filter works. It's not necessary to understand these details for basic usage.

  1. The filter examines the HTML content of your feeds.
  2. It uses the provided CSS selector (default: "img") and domain list (if specified) to determine which image URLs to rewrite.
  3. For matching images, it rewrites the src attribute to point to the proxy URL (either the built-in proxy endpoint or the external proxy URL).
  4. When a user's RSS reader tries to load the image, the request goes through the proxy.
  5. For the built-in proxy:
    • The proxy endpoint validates the request using a signing key for security.
    • It then fetches the original image using the specified parameters (referer, user-agent, etc.).
    • The image is served to the user's RSS reader.

This process allows images to be loaded through the proxy, potentially bypassing restrictions set by the original image host.

Security and Persistence

The built-in proxy uses a signing key to prevent abuse and ensure that only requests generated by your RSS Funnel instance are processed. By default, this key is randomly generated each time the application starts. However, if you need the proxy URLs to remain valid across restarts, you can set a persistent signing key:

  1. Set the environment variable RSS_FUNNEL_IMAGE_PROXY_SIGN_KEY to a fixed string before launching the app.
  2. This ensures that the same signing key is used across restarts, making the proxy URLs reusable.

For example:

export RSS_FUNNEL_IMAGE_PROXY_SIGN_KEY="your-secret-key-here"
./rss-funnel

Remember to keep this key secret, as it's used to validate proxy requests.