Nginx config for staging application

resolver 172.17.0.1; resolver_timeout 10s; server { listen 80; server_name staging.app.com; charset utf-8; gzip_vary on; access_log /var/log/nginx/app.access.log; error_log /var/log/nginx/app.error.log; add_header ‘Access-Control-Allow-Origin’ ‘*’ always; add_header ‘Access-Control-Allow-Methods’ ‘GET, POST, OPTIONS, PUT, DELETE’ always; add_header X-Frame-Options “SAMEORIGIN”; set $appweb http://app-web.service.consul; location / { proxy_pass $appweb:5002; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; … Read more

Bash script to run terraform recursively

#!/bin/bash cd prd && ls -d */ declare -a dirs i=1 for d in */ do dirs[i++]=”${d%/}” done echo “There are ${#dirs[@]} dirs in the current path” for((i=1;i<=${#dirs[@]};i++)) do cd “${dirs[i]}” && rm -rf .terraform \ && echo “terraform {” > backend.tf \ && echo “backend \”consul\” {” >> backend.tf \ && echo “}” >> … Read more

Docker command cheatsheet

docker build image $ sudo docker build -t image-name . docker to start a container from image $ sudo docker run -itd –name jenkins –publish 8080:8080 –publish 50000:50000 jenkins docker to get inside the container $ sudo docker exec -it jenkins bash docker stop container $ sudo docker stop image-id/name docker remove container $ sudo … Read more