Skip to content

Instantly share code, notes, and snippets.

View rameerez's full-sized avatar
creating

rameerez rameerez

creating
View GitHub Profile
@rameerez
rameerez / aws-ubuntu-server-22-04-ec2-instance-setup-for-rails-7-capistrano.sh
Last active January 12, 2024 01:56
Configure an AWS EC2 instance running Ubuntu Server 22.04 LTS to run a Rails 7 app using Capistrano for deployment
#!/bin/bash
# This scrips takes a clean Ubuntu Server 20.04 LTS AMI and installs and configures
# everything needed to deploy a Rails app to it. The resulting state is a clean
# instance that can be used to build a base AMI in AWS.
# --- AESTHETICS ---
# Define the color code for green for echo messages
@rameerez
rameerez / aws-ec2-rails-user-data.sh
Last active May 3, 2023 17:28
User data to perform the initial set up of an AWS EC2 machine after running the AMI script
#!/bin/bash
# This scripts performs the initial setup for an EC2 AMI that has
# been previously prepared to accept Rails apps.
# --- USER DATA SCRIPT STARTS ---
# Configure SSH key for the rails user (same as ubuntu, AWS configured key)
sudo mkdir /home/rails/.ssh
@rameerez
rameerez / aws-al2023-ec2-instance-setup-for-rails-7-capistrano.sh
Last active May 3, 2023 16:40
Configure an AWS EC2 instance running Amazon Linux 2023 (AL2023) to run a Rails 7 app using Capistrano for deployment
#!/bin/bash
# This scrips takes a clean AWS Amazon Linux 2023 AMI and installs and configures
# everything needed to deploy a Rails app to it. The resulting state is a clean
# instance that can be used to build a base AMI for an EC2 ASG.
# --- AESTHETICS ---
# Define the color code for green for echo messages
@rameerez
rameerez / listmonk-s3-policy.json
Created February 23, 2023 20:04
AWS IAM policy for a Listmonk user to access only one S3 bucket
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:PutBucketPublicAccessBlock",
@rameerez
rameerez / mail.example.com.conf
Last active March 29, 2024 04:12
Nginx configuration for Listmonk running on Docker port 9000 using SSL certificates provided by Bitnami on AWS Lightsail
# This file goes in /opt/bitnami/nginx/conf/server_blocks as mail.example.com.conf (make sure to replace the filename with your actual subdomain)
# This Nginx config file assumes we're runing a Bitnami image (thus the non-standard /opt/bitnami paths)
# FULL TUTORIAL to set up Listmonk on AWS Lightsail here: https://rameerez.com/free-mailchimp-alternative-email-marketing-service#listmonk-tutorial
server {
listen 443 ssl;
server_name mail.example.com;
server_tokens off;
ssl_certificate /opt/bitnami/letsencrypt/certificates/mail.example.com.crt;
@rameerez
rameerez / add-new-website.sh
Last active June 16, 2023 11:57
Script to set up a new site with SSL cert in a Unix (Apache VirtualHost) server
#!/bin/sh
# Should be run as sudo
# Usage: add-new-website.sh domain -- script to set up a new site with SSL cert
# where:
# domain website domain without subdomains (ex: example.com)
if [ ! -z "$1" ]
then