Skip to content

Instantly share code, notes, and snippets.

View saissemet's full-sized avatar
💣
I'm a bomb.

Messias Rodrigues saissemet

💣
I'm a bomb.
View GitHub Profile
@saissemet
saissemet / apache_self_signed.sh
Last active April 2, 2024 09:34
Apache website with self signed certificates
sudo apt update && sudo apt upgrade -y
sudo apt install apache2 -y
sudo apt install easy-rsa -y
cd /usr/share/easy-rsa
sudo ./easyrsa init-pki
yes "" | sudo ./easyrsa build-ca nopass
@saissemet
saissemet / .Multiple EC2 Instances using Terraform
Last active January 22, 2024 04:17
Creating multiple EC2 instances using Terraform
## Step 1 ##
In your current user directory, create a folder named ".aws".
Also create a file named "credentials" with your AWS credentials.
## Step 2 ##
Download Terraform (https://releases.hashicorp.com/terraform/0.14.7/terraform_0.14.7_windows_amd64.zip)
Create a folder with a name of your taste and place the "terraform.exe" file.
## Step 3 ##
In that same folder you just created, create the files: "provider.tf", "variables.tf", "main.tf" and "config.sh".
## Download link: https://we.tl/t-mUDSSDVmff
apt update && apt upgrade -y
apt install docker.io -y
echo "'apache2' or 'nginx'?"
read var1
if [[ "$var1" =~ ^([n][g][i][n][x])$ ]]
then
## In this tutorial we are creating a simple Apache2 docker image. The main ideia is to create and push a docker image from scratch. ##
## Creating a local directory to store the configuration files ##
mkdir myapp
cd myapp
## Creating a "Dockerfile" with the following content ##
nano Dockerfile
FROM ubuntu:18.04
//Topology:
172.31.0.11/24 (With Assossiated Elastic IP)
__________
| |
| |
| CLIENT |
| |
|__________|
172.31.1.11/24
./easy-rsa init-pki
## Build the ca.crt ##
./easy-rsa build-ca nopass
## Generate a certificate request. This command automatically creates the private key (.pki file) ##
./easy-rsa gen-req <Server Name> nopass
## Self-sign the certificate to create the .crt file ##
./easy-rsa sign-req <Server Name> nopass
## We'll be creating and protecting a new website folder named "private" with the user "saissemet". ##
sudo mkdir /var/www/html/private
sudo echo 'saissemet' >> /var/www/html/private/index.html
sudo nano /etc/nginx/sites-available/default
location /private/ {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd1;
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name ec2-54-152-84-236.compute-1.amazonaws.com;
ssl_certificate /etc/ssl/certs/ec2-54-211-232-203.compute-1.amazonaws.com.crt;
ssl_certificate_key /etc/ssl/private/ec2-54-211-232-203.compute-1.amazonaws.com.key;
root /var/www/htmls;
index index.html;
server {
listen 8443 ssl;
listen [::]:8443 ssl;
server_name ec2-54-152-84-236.compute-1.amazonaws.com;
ssl_certificate /etc/ssl/certs/ec2-54-211-232-203.compute-1.amazonaws.com.crt;
ssl_certificate_key /etc/ssl/private/ec2-54-211-232-203.compute-1.amazonaws.com.key;
ssl_client_certificate /etc/ssl/certs/ca.crt;
ssl_verify_client optional;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
## We'll be creating and protecting a new website folder named "secreta" with the user "saissemet". ##
sudo nano /var/www/htmls/secreta/.htaccess
AuthType Basic
AuthName "Password Required"
Require valid-user
AuthUserFile /etc/apache2/.htpasswd
sudo nano /etc/apache2/sites-available/default-ssl.conf
<Directory /var/www/htmlapaches>