Skip to content

Instantly share code, notes, and snippets.

View thebongy's full-sized avatar
🎯
Focusing

Rishit Bansal thebongy

🎯
Focusing
View GitHub Profile
@thebongy
thebongy / install-docker.sh
Last active July 27, 2020 11:44
Installing Docker on Ubuntu
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
version: '2'
services:
ctfd:
build: .
user: root
restart: always
ports:
- "8000:8000"
environment:
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=10r/s;
limit_conn_zone $binary_remote_addr zone=addr:10m;
server {
server_name mydomain.com;
limit_req zone=mylimit burst=15;
limit_conn addr 10;
limit_req_status 429;
client_max_body_size 8M;
location / {
proxy_pass http://localhost:8000;
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install certbot python3-certbot-nginx
# Add apt sources
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
# Install deps
sudo apt-get install apt-transport-https ca-certificates gnupg
# Import google cloud public key
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
# Update apt package index, install cloud sdk
gcloud container clusters create cluster-name \
--zone compute-zone \
--machine-type <machine-type you chose> \
--num-nodes <number of nodes in the cluster> \
--tags challenges
apiVersion: apps/v1
kind: Deployment
metadata:
name: challenge-name # REPLACE challenge-name and challenge-category to your challenges's name and category
labels:
category: challenge-category # We assign labels to the deployment to link it to a service later, and to help manage deployments
challenge: challenge-name
spec:
replicas: 3 # The no of replicas sets the no of instances/pods of the challenge deployed on the cluster
selector:
gcloud compute firewall-rules create challenge-name \
--allow tcp:30001 \
--priority 1000 \
--target-tags challenges
# The first two global and default sections
# are just the ones present by default in the config file
# We leave these unchanged
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s