Deploying AcuSensor for PHP - Docker

The most principled way of deploying AcuSensor in a Docker scenario is to simply layer the AcuSensor modifications onto your already existing container definition. This simple example will demonstrate how you can deploy AcuSensor together with your web application.

Create your Target in Acunetix

For this example, we will assume that the URL for your target is http://acunetixexample.com:60000. Create a target with your URL, enable AcuSensor, download the AcuSensor agent file acusensor.php, and save this file for use later on.

Define the Web Application image

This simple web application will be defined through the following file structure:

/testphp-docker/

/testphp-docker/Dockerfile

/testphp-docker/websrc/

/testphp-docker/websrc/index.php

/testphp-docker/websrc/test.php

Create your /testphp-docker/Dockerfile file to read as follows:

FROM php:7.3.28-apache

#setup the web pages

COPY --chown=www-data:www-data websrc/ /var/www/html

Create your /testphp-docker/websrc/index.php file to read as follows:

<?php

    echo "<h1>Test PHP Site Example for Docker Deployment</h1>";

    echo "<br>";

    echo "Welcome to the main page.";

    echo "<br>";

    echo "<a href='test.php'>Go to the test page.</a>";

?>

Create your /testphp-docker/websrc/test.php file to read as follows:

<?php

    echo "<h1>Test PHP Site Example for Docker Deployment</h1>";

    echo "<br>";

    echo "Welcome to the test page.";

    echo "<br>";

?>

Finally, build the image with:

cd /testphp-docker

docker build -t testphp-docker .

Define the AcuSensor layer image

The AcuSensor layer will be defined through the following file structure:

/testphp-docker-acusensor/

/testphp-docker-acusensor/Dockerfile

/testphp-docker-acusensor/acusensor.php

Copy the acusonsor.php file you created in the first step to your docker host into the /testphp-docker-acusensor directory.

Create your /testphp-docker-acusensor/Dockerfile file to read as follows:

FROM acunetix-test/testphp-docker

# assumes the web application is in /var/www/html

# setup AcuSensor

RUN mkdir /acusensor

WORKDIR /acusensor

COPY acusensor.php .

# add .htaccess file for AcuSensor

RUN printf "\nphp_value auto_prepend_file /acusensor/acusensor.php\n" > /var/www/html/.htaccess \

  && chown www-data:www-data /var/www/html/.htaccess

Build and run your image with:

cd /testphp-docker-acusensor

docker build -t testphp-docker-acusensor .

docker run -d -p 60000:80 --name mytestphp testphp-docker-acusensor

Test and scan your web application

Point your browser to your web application - in this example http://acunetixexample.com:6000 to confirm it is running as intended; you will get the following:

Finally, run a scan on your target; the Activity panel will confirm that AcuSensor was detected and used for the scan.

 

« Back to the Acunetix Support Page