feat: refs #7022 Added cdn #5
|
@ -1,20 +1,10 @@
|
||||||
FROM httpd:2.4.60
|
FROM httpd:2.4.61
|
||||||
|
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install -y curl libcgi-pm-perl \
|
&& apt-get install -y curl libcgi-pm-perl \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN echo "ServerName localhost\n" \
|
COPY www/rwmap.pl /usr/local/bin/
|
||||||
"Include conf/extra/httpd-vhosts.conf\n" \
|
RUN chmod +x /usr/local/bin/rwmap.pl
|
||||||
"LoadModule rewrite_module modules/mod_rewrite.so\n" \
|
|
||||||
"LoadModule cgid_module modules/mod_cgid.so\n" \
|
|
||||||
"LoadModule proxy_module modules/mod_proxy.so\n" \
|
|
||||||
"LoadModule proxy_http_module modules/mod_proxy_http.so" \
|
|
||||||
>> "/usr/local/apache2/conf/httpd.conf"
|
|
||||||
|
|
||||||
COPY apache2.conf /usr/local/apache2/conf/extra/httpd-vhosts.conf
|
RUN echo "IncludeOptional conf.d/*.conf" >> conf/httpd.conf
|
||||||
|
|
||||||
COPY rwmap.pl /usr/local/apache2/htdocs/
|
|
||||||
RUN chmod +x /usr/local/apache2/htdocs/rwmap.pl
|
|
||||||
|
|
||||||
CMD ["httpd-foreground"]
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
<VirtualHost *:80>
|
|
||||||
DocumentRoot /usr/local/apache2/htdocs
|
|
||||||
|
|
||||||
RewriteEngine On
|
|
||||||
RewriteMap rwmap prg:/usr/local/apache2/htdocs/rwmap.pl
|
|
||||||
RewriteRule ^/image/catalog/(.+)$ ${rwmap:$1} [PT,QSA]
|
|
||||||
|
|
||||||
<Proxy *>
|
|
||||||
Require all granted
|
|
||||||
</Proxy>
|
|
||||||
|
|
||||||
<Directory "/usr/local/apache2/htdocs">
|
|
||||||
Options Indexes FollowSymLinks ExecCGI
|
|
||||||
AllowOverride All
|
|
||||||
Require all granted
|
|
||||||
AddHandler cgi-script .pl
|
|
||||||
</Directory>
|
|
||||||
</VirtualHost>
|
|
25
cdn/rwmap.pl
25
cdn/rwmap.pl
|
@ -4,32 +4,23 @@ use warnings;
|
||||||
use Digest::SHA qw(sha1_hex);
|
use Digest::SHA qw(sha1_hex);
|
||||||
# Desactiva el buffering de salida para que Apache pueda obtener la respuesta inmediatamente
|
# Desactiva el buffering de salida para que Apache pueda obtener la respuesta inmediatamente
|
||||||
$| = 1;
|
$| = 1;
|
||||||
my $serverName = $ENV{'SERVER_NAME'} || 'localhost';
|
|
||||||
my $serverPort = $ENV{'SERVER_PORT'} || '80';
|
|
||||||
my $scheme = ($serverPort == 443) ? 'https' : 'http';
|
|
||||||
my $baseUrl = "$scheme://$serverName";
|
|
||||||
$baseUrl .= ":$serverPort" if ($serverPort != 80 && $serverPort != 443);
|
|
||||||
|
|
||||||
while (<STDIN>) {
|
while (<STDIN>) {
|
||||||
chomp;
|
chomp;
|
||||||
my $input = $_;
|
my $input = $_;
|
||||||
my ($path, $filename) = split('/', $input);
|
$input =~ /^\/image\/(.*)\/([a-z0-9-_]+)\.(png)$/;
|
||||||
|
my $collection = $1;
|
||||||
if (defined $filename && $filename =~ /^(.+)\.(\w+)$/) {
|
my $name = $2;
|
||||||
my $name = $1;
|
my $extension = $3;
|
||||||
my $extension = $2;
|
|
||||||
|
|
||||||
my $sha1 = sha1_hex($name);
|
my $sha1 = sha1_hex($name);
|
||||||
my $first = substr($sha1, 0, 2);
|
my $first = substr($sha1, 0, 2);
|
||||||
my $last = substr($sha1, 1, 2);
|
my $last = substr($sha1, 1, 2);
|
||||||
|
my $newPath = "images/$collection/$first/$last/$name.$extension";
|
||||||
|
|
||||||
if (-e "images/catalog/$path/$first/$last/$name.$extension") {
|
if (-e "/usr/local/apache2/htdocs/$newPath") {
|
||||||
print "$baseUrl/images/catalog/$path/$first/$last/$name.$extension\n";
|
print "/$newPath\n";
|
||||||
}
|
|
||||||
else {
|
|
||||||
print "$baseUrl/images/catalog/$path/$name.$extension\n";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
print "Status: 400 Bad Request\n";
|
print "/image/$input\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue