Bỏ qua để đến nội dung
ViGrise Platform

HTTP Source

Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.

The HTTP source is the default source in PreviewProxy and is always enabled. It allows you to proxy and transform any publicly accessible image over HTTP or HTTPS.

Include the full image URL (starting with http:// or https://) as the last segment of the request path:

/<params>/<image_url>

Example:

/w=400/https://example.com/photo.jpg

The image URL in the path is URL-decoded automatically. This means you can percent-encode the URL if needed - for example, when embedding the proxy URL inside another URL or passing it through systems that require encoding:

/w=400/https%3A%2F%2Fexample.com%2Fphoto.jpg

Both the encoded and plain forms are handled correctly.

The HTTP source behaviour is controlled by the following environment variables:

VariableDefaultDescription
PP_ALLOWED_HOSTS(unset)Comma-separated list of allowed hostnames. If set, only these hosts may be proxied.
PP_FETCH_TIMEOUT_SECS10Maximum time in seconds to wait for the upstream server to respond.
PP_MAX_SOURCE_BYTES20971520 (20 MB)Maximum size of the source image that will be downloaded.

By default, PreviewProxy will fetch images from any public host. To restrict which domains are permitted, set PP_ALLOWED_HOSTS:

Terminal window
PP_ALLOWED_HOSTS=example.com,assets.mysite.com

If the upstream server takes longer than PP_FETCH_TIMEOUT_SECS to respond, the request will be aborted and an error returned to the client.

Terminal window
PP_FETCH_TIMEOUT_SECS=30

Requests for images exceeding PP_MAX_SOURCE_BYTES will be rejected before the full body is downloaded.

Terminal window
PP_MAX_SOURCE_BYTES=10485760 # 10 MB

This prevents server-side request forgery (SSRF) attacks where an attacker could use the proxy to reach internal network services.