This commit is contained in:
parent
21dfbb4696
commit
f912503dec
|
@ -4,18 +4,17 @@ RUN apt-get update \
|
|||
&& apt-get install -y curl libcgi-pm-perl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ARG HTTPD_PATH="/usr/local/apache2/conf/httpd.conf"
|
||||
|
||||
RUN echo "ServerName localhost" >> ${HTTPD_PATH} \
|
||||
&& echo "Include conf/extra/httpd-vhosts.conf" >> ${HTTPD_PATH} \
|
||||
&& echo "LoadModule rewrite_module modules/mod_rewrite.so" >> ${HTTPD_PATH} \
|
||||
&& echo "LoadModule cgid_module modules/mod_cgid.so" >> ${HTTPD_PATH} \
|
||||
&& echo "LoadModule proxy_module modules/mod_proxy.so" >> ${HTTPD_PATH} \
|
||||
&& echo "LoadModule proxy_http_module modules/mod_proxy_http.so" >> ${HTTPD_PATH}
|
||||
RUN echo "ServerName localhost\n" \
|
||||
"Include conf/extra/httpd-vhosts.conf\n" \
|
||||
"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
|
||||
COPY www/ /usr/local/apache2/htdocs/
|
||||
|
||||
RUN chmod +x /usr/local/apache2/htdocs/redirect.pl
|
||||
RUN chmod +x /usr/local/apache2/htdocs/rwmap.pl
|
||||
|
||||
CMD ["httpd-foreground"]
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
DocumentRoot /usr/local/apache2/htdocs
|
||||
|
||||
RewriteEngine On
|
||||
RewriteMap mymap prg:/usr/local/apache2/htdocs/redirect.pl
|
||||
RewriteRule ^/image/catalog/(.+)$ ${mymap:$1} [P]
|
||||
RewriteMap rwmap prg:/usr/local/apache2/htdocs/rwmap.pl
|
||||
RewriteRule ^/image/catalog/(.+)$ ${rwmap:$1} [P]
|
||||
|
||||
<Proxy *>
|
||||
Require all granted
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Digest::SHA qw(sha1_hex);
|
||||
|
||||
# Desactiva el buffering de salida para que Apache pueda obtener la respuesta inmediatamente
|
||||
$| = 1;
|
||||
|
||||
while (<STDIN>) {
|
||||
chomp;
|
||||
my $input = $_;
|
||||
print STDERR "DEBUG: Input recibido: $input\n"; # Mensaje de depuración
|
||||
my ($path, $filename) = split('/', $input);
|
||||
|
||||
if ($filename =~ /^(.+)\.(\w+)$/) {
|
||||
my $name = $1;
|
||||
my $extension = $2;
|
||||
|
||||
my $sha1 = sha1_hex($name);
|
||||
my $first = substr($sha1, 0, 2);
|
||||
my $last = substr($sha1, 1, 2);
|
||||
print "http://localhost/images/catalog/$path/$first/$last/$name.$extension\n";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Digest::SHA qw(sha1_hex);
|
||||
# Desactiva el buffering de salida para que Apache pueda obtener la respuesta inmediatamente
|
||||
$| = 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>) {
|
||||
chomp;
|
||||
my $input = $_;
|
||||
print STDERR "DEBUG: Input recibido: $input\n"; # Mensaje de depuración
|
||||
my ($path, $filename) = split('/', $input);
|
||||
|
||||
if (defined $filename && $filename =~ /^(.+)\.(\w+)$/) {
|
||||
my $name = $1;
|
||||
my $extension = $2;
|
||||
|
||||
my $sha1 = sha1_hex($name);
|
||||
my $first = substr($sha1, 0, 2);
|
||||
my $last = substr($sha1, 1, 2);
|
||||
|
||||
if (-e "images/catalog/$path/$first/$last/$name.$extension") {
|
||||
print "$baseUrl/images/catalog/$path/$first/$last/$name.$extension\n";
|
||||
}
|
||||
else {
|
||||
print "$baseUrl/images/catalog/$path/$name.$extension\n";
|
||||
}
|
||||
} else {
|
||||
print "Status: 400 Bad Request\n";
|
||||
print "Content-type: text/plain\n\n";
|
||||
print "Error: Invalid filename\n";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue