2022-11-07

AWS EC2 Amazon Linux

#https://dev.to/viralsangani/be-anonymous-create-your-own-proxy-server-with-aws-ec2-2k63

#1) amazon linux

#2) spot instance (permanent)

#3) key ssh

#4) network group All,ssh,http, https


#!/bin/bash

sudo yum update -y

sudo yum install -y httpd

sudo systemctl start httpd

sudo systemctl enable httpd

cd /var/www/html

sudo sh -c 'echo "hello from $(hostname -f)" > /var/www/html/index.html'


####################

 #If you are using Amazon Linux 2023 (AL2023)

# 1. Install compilation tools and dependencies

sudo dnf groupinstall -y "Development Tools"

sudo dnf install -y asciidoc


# 2. Download and extract the latest Tinyproxy release

cd /tmp

wget https://github.com/tinyproxy/tinyproxy/releases/download/1.11.1/tinyproxy-1.11.1.tar.gz

tar -xzf tinyproxy-1.11.1.tar.gz

cd tinyproxy-1.11.1

./configure --prefix=/usr --sysconfdir=/etc

make

sudo make install


# 4. Create a systemd service file so it can run as a daemon

sudo tee /etc/systemd/system/tinyproxy.service > /dev/null << 'EOF'

[Unit]

Description=Tinyproxy lightweight HTTP proxy

After=network.target


[Service]

Type=simple

ExecStart=/usr/bin/tinyproxy -d -c /etc/tinyproxy/tinyproxy.conf

User=nobody

Group=nobody

Restart=on-failure


[Install]

WantedBy=multi-user.target

EOF


# 5. Create required runtime directory and permissions

sudo mkdir -p /var/run/tinyproxy

sudo chown nobody:nobody /var/run/tinyproxy

#####################

sudo sed -i 's/^Allow 127\.0\.0\.1$/#Allow 127.0.0.1/' /etc/tinyproxy/tinyproxy.conf

sudo sed -i 's/^Allow ::1$/#Allow ::1/' /etc/tinyproxy/tinyproxy.conf


# 6. Enable and start the service

sudo systemctl daemon-reload

sudo systemctl enable --now tinyproxy



#curl -i -x http://YOUR_EC2_PUBLIC_IP:8888 http://ifconfig.me