apache in docker to serve local website

I have some backup’s of website on my laptop, which I occasionally want to view. Now, I could have setup apache to serve them directly with VirtualHost or alias but wanted a better solution. So, docker comes to rescue.

First, I installed fedora-dockerfiles and then made some modifications, here they are :

sudo yum install fedora-dockerfiles

After this is done, go to /usr/share/fedora-dockerfiles/apache and make some modification to Dockerfile.  After the modifications, the file looks like this

FROM fedora
MAINTAINER “Scott Collier” <[email protected]>

RUN yum -y update; yum clean all
RUN yum -y install httpd; yum clean all
RUN echo “Apache” >> /var/www/html/index.html

EXPOSE 80

# Simple startup script to avoid some issues observed with container restart
ADD run-apache.sh /run-apache.sh
ADD php.conf /etc/httpd/conf.d/php.conf
RUN chmod -v +x /run-apache.sh
RUN yum -y install php

CMD [“/run-apache.sh”]

 

Now copy the php.conf file to current directory.

sudo cp /etc/httpd/conf.d/php.conf .

#Build the docker image
docker build --rm -t apache .

#and then quickly test the image like this -
docker run -t -i --rm -p 80:80 apache

#open the site in firefox
firefox -new-tab http://loccalhost

Once you see that the docker is running fine, time to create a script to do this in your desired directory.
I always have “~/bin” in $PATH, so I created ~/bin/docker.sh file with the following contents:

#!/bin/bash -
#===============================================================================
#
#          FILE: docker_firefox.sh
#
#         USAGE: ./docker_firefox.sh
#
#   DESCRIPTION:
#
#       OPTIONS: ---
#  REQUIREMENTS: ---
#          BUGS: ---
#         NOTES: ---
#        AUTHOR: Amit Agarwal (aka)
#      REVISION:  ---
#===============================================================================

dir="your/desired/directory/with/content/for/website"
echo "Run Ubu website:::"
CID=$(docker run  -d -p 80:80  -v $dir:/var/www/html:ro apache)
echo docker CID is $CID
firefox -new-tab http://localhost/index.php

After this time to test:

Just run this script and you should have the contents of current directory in your browser.

PHP Image gallery with fancybox.

So, I was looking for some quick to setup PHP Image gallery file. I found couple but none of them suited my needs too well. So I had to write my own.

Very simple PHP script to show all the images under ‘images’ folder.

Shows some details in the images.

 

That is all that I wanted and that is all that this script does. So pretty simple single php file. Dependency is on fancybox so you will need the jquery and all but nothing else is required.

https://github.com/raj77in/PHP-ImagaeGallery.git

Search CVE – web interface with php

So, last few weeks have been very busy with lot of security issues, so I thought of having a local CVE Search app. But all I could find on google and github.com were on python and nothing that I could use quickly. So here is link to one that I wrote quickly:

CVE Search PHP

 

It’s in php. So just download in some folder and access from a web-server and you are done.