HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/alq-cali.bikenow.co/vendor/league/glide/docs/0.3/config/secure-images.md
---
layout: default
title: Secure images
---

# Secure images

Add additional security to your Glide image server with HTTP signatures. By signing each request with a private key, no alterations can be made to the URL parameters.

<p class="message-notice">It is highly recommended that you use secure URLs in production environments.</p>

## Configuration

Start by configuring the Glide server to validate each request before you ouput the image. In the event that the validation fails, Glide will throw an `SignatureException` exception.

~~~ php
<?php

use League\Glide\Http\SignatureFactory;
use League\Glide\Http\SignatureException;
use Symfony\Component\HttpFoundation\Request;

// Create request object
$request = Request::createFromGlobals();

// Validate HTTP signature
try {
    SignatureFactory::create('your-sign-key')->validateRequest($request);
} catch (SignatureException $e) {
    // Handle error
}
~~~

## Generating secure URLs

Next, generate a signature for each image request you make. Glide comes with a URL builder to make this process easy. Be sure to use the same signing key you configured earlier.

~~~ php
<?php

use League\Glide\Http\UrlBuilderFactory;

// Create an instance of the URL builder
$urlBuilder = UrlBuilderFactory::create('http://example.com', 'your-sign-key');

// Generate a URL
$url = $urlBuilder->getUrl('cat.jpg', ['w' => 500]);

// Use the URL in your app
echo '<img src="'.$url.'">';

// Prints out
<img src="http://example.com/img/cat.jpg?w=500&token=af3dc18fc6bfb2afb521e587c348b904">
~~~