Home

Awesome

Apache Mod_Rewrite Terrafrom Automation

Image

Bash scripts that take variables from the user and then call terraform scripts to automate standing up apache2 with mod_rewrite in front of C2 servers. Right now, this repo supports standing up redirectors in Linode or Digital Ocean, and I have different scripts for standing up http redirectors versus https redirectors. Since the mod_rewrite redirector setup scripts use a user agent value and optionally a bearer token, these redirectors are not C2 dependent and can work for any C2 that uses http or https.

These bash and terraform scripts were built to be run on either Linux or macOS hosts, and first check to see if you have terraform installed. If terraform is not installed, the script will attempt to install it for you before proceeding.

NOTE: After running, terraform will start apache2 using the root user account. It is recommended that you log in, create a local user with sudo, and restart apache using that user account rather than root, since running tools as root is not recommended

Prerequisites

Instructions

cd into directory of your choice

chmod +x *.sh

./[bash_script_you_are_running]

Info on the types of bash scripts include

1. LINODE REDIRECTOR SCRIPTS:

The bash scripts above take the following inputs:

Bash will then perform all of the variable replacements in the local init.tf, htaccess, and 000-default.conf files and then kick off a terraform plan and apply. Once you agree to the apply then terraform will stand up the Redirector in Linode. If you are using the Linode_ssl_redirector/Linode-mod_rewrite-redirector-setup.sh terraform will also install and run certbot to take care of letsencrypt certs for the domain you provided. Once done you can browse to your domain and everything will be up and running.

2. DIGITAL OCEAN REDIRECTOR SCRIPTS:

The bash scripts above take the following inputs:

Bash will then perform all of the variable replacements in the local init.tf, htaccess, and 000-default.conf files and then kick off a terraform plan and apply. Once you agree to the apply then terraform will stand up the Redirector in DO. If you are using the DO_ssl_redirector/DO-mod_rewrite-redirector-setup.sh terraform will also install and run certbot to take care of letsencrypt certs for the domain you provided. Once done you can browse to your domain and everything will be up and running.