FROM httpd:latest # Habilitar mod_rewrite y configurar Apache RUN apt-get update && apt-get install -y curl libcgi-pm-perl # Habilitar mod_rewrite y mod_cgi RUN sed -i '/mod_rewrite/s/^#//g' /usr/local/apache2/conf/httpd.conf RUN sed -i '/mod_cgi/s/^#//g' /usr/local/apache2/conf/httpd.conf RUN echo "AddHandler cgi-script .cgi .pl" >> /usr/local/apache2/conf/httpd.conf RUN echo "Include conf/extra/httpd-vhosts.conf" >> /usr/local/apache2/conf/httpd.conf # Habilitar mod_cgi RUN sed -i '/mod_cgi/s/^#//g' /usr/local/apache2/conf/httpd.conf RUN echo "LoadModule cgid_module modules/mod_cgid.so" >> /usr/local/apache2/conf/httpd.conf # Habilitar mod_rewrite si aún no está habilitado RUN sed -i '/mod_rewrite/s/^#//g' /usr/local/apache2/conf/httpd.conf # Configurar Apache para ejecutar scripts CGI # RUN echo "ScriptAlias /cgi-bin/ \"/usr/local/apache2/cgi-bin/\"" >> /usr/local/apache2/conf/httpd.conf # RUN echo "" >> /usr/local/apache2/conf/httpd.conf # RUN echo " AllowOverride None" >> /usr/local/apache2/conf/httpd.conf # RUN echo " Options +ExecCGI" >> /usr/local/apache2/conf/httpd.conf # RUN echo " Require all granted" >> /usr/local/apache2/conf/httpd.conf # RUN echo "" >> /usr/local/apache2/conf/httpd.conf # Configurar Apache para ejecutar scripts CGI # RUN echo "" >> /usr/local/apache2/conf/httpd.conf # RUN echo " Options +ExecCGI" >> /usr/local/apache2/conf/httpd.conf # RUN echo " AllowOverride None" >> /usr/local/apache2/conf/httpd.conf # RUN echo " AddHandler cgi-script .cgi .pl" >> /usr/local/apache2/conf/httpd.conf # RUN echo " Require all granted" >> /usr/local/apache2/conf/httpd.conf # RUN echo "" >> /usr/local/apache2/conf/httpd.conf # Copiar scripts CGI al directorio correspondiente COPY cgi-bin/ /usr/local/apache2/cgi-bin/ # Copiar la configuración de Apache2 y los archivos del sitio COPY apache2.conf /usr/local/apache2/conf/extra/httpd-vhosts.conf # RUN chmod +x www/script.pl COPY www/ /usr/local/apache2/htdocs/ # Copia las imágenes al directorio htdocs/images # COPY images/ /usr/local/apache2/htdocs/images/ # Copia el archivo .htaccess para configurar el directorio htdocs/images COPY .htaccess /usr/local/apache2/htdocs/ RUN chmod +x /usr/local/apache2/htdocs/script.pl RUN chmod +x /usr/local/apache2/cgi-bin/script.pl # Habilitar reescritura y reiniciar Apache2 RUN echo "RewriteEngine On" >> /usr/local/apache2/conf/extra/httpd-vhosts.conf RUN echo "Include conf/extra/httpd-vhosts.conf" >> /usr/local/apache2/conf/httpd.conf # CMD y ENTRYPOINT para iniciar Apache2, según la imagen original CMD ["httpd-foreground"]