Skip to content

Instantly share code, notes, and snippets.

@jtadeulopes
jtadeulopes / server.md
Last active March 29, 2024 10:23
Server setup with ubuntu, nginx and puma for rails app.

Update and upgrade the system

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade && sudo apt-get autoremove
sudo reboot

Configure timezone

@jtadeulopes
jtadeulopes / block.sh
Created February 24, 2014 16:18
Iptables rules
# sudo sh block.sh
iptables -I INPUT 1 -p tcp --dport 80 -m string --string "ads.yahoo.com" --algo kmp -j DROP
iptables -I INPUT 1 -p tcp --dport 80 -m string --string "ads.fcmrktplace.com" --algo kmp -j DROP
iptables -I INPUT 1 -p tcp --dport 80 -m string --string "ads.creafi-online-media.com" --algo kmp -j DROP
iptables -I INPUT 1 -p tcp --dport 80 -m string --string "ib.reachjunction.com" --algo kmp -j DROP
iptables -I INPUT 1 -p tcp --dport 80 -m string --string "www.indeed.com" --algo kmp -j DROP
iptables -I INPUT 1 -p tcp --dport 80 -m string --string "ib.adnxs.com" --algo kmp -j DROP
iptables -I INPUT 1 -p tcp --dport 80 -m string --string "ad.tagjunction.com" --algo kmp -j DROP
iptables -I INPUT 1 -p tcp --dport 80 -m string --string "ad.globe7.com" --algo kmp -j DROP
iptables -I INPUT 1 -p tcp --dport 80 -m string --string "ads.clicksor.com" --algo kmp -j DROP
@jtadeulopes
jtadeulopes / localhost_https.conf
Last active May 30, 2021 14:26
Nginx config with https support
upstream project {
server unix:///var/tmp/project.sock;
}
server {
listen 80 default_server;
server_name project.com;
return 301 https://$server_name$request_uri;
}
@jtadeulopes
jtadeulopes / nginx.conf
Last active December 9, 2019 11:37
Nginx settings
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
@jtadeulopes
jtadeulopes / es-semaphore.sh
Last active November 24, 2019 06:54
A script for installing ES on SemaphoreCI
#! /usr/bin/env bash
## Usage:
## wget https://gist.githubusercontent.com/jtadeulopes/ae1f1ffe53000012b27b1112aecaa4b7/raw/45f792729d8b26e42f07028d0693e4de51024383/es-semaphore.sh && bash es-semaphore.sh <es-version>
##
ES_HOST="0.0.0.0"
ES_PORT="9200"
ES_VERSION=${1:-'5.0.0'}
DEB='elasticsearch-'"$ES_VERSION"'.deb'
@jtadeulopes
jtadeulopes / project.conf
Last active December 20, 2018 05:42
Puma upstart
description "project server config"
pre-start script
mkdir -p /var/log/puma
chown deploy. /var/log/puma
mkdir -p /var/run/puma
chown deploy. /var/run/puma
end script
@jtadeulopes
jtadeulopes / Capfile
Last active January 8, 2018 16:36
Capfile
require 'bundler/capistrano'
load 'deploy'
load 'deploy/assets'
load 'config/deploy' # remove this line to skip loading any of the default tasks
@jtadeulopes
jtadeulopes / puma.rb
Last active November 22, 2017 09:48
Puma config
#!/usr/bin/env puma
threads 0, 4
# workers 3
bind "unix:///var/tmp/project.sock"
pidfile "/var/run/puma/project.pid"
environment "production"
stdout_redirect "/var/log/puma/project.log"
@jtadeulopes
jtadeulopes / deploy.rb
Last active November 22, 2017 09:48
Capistrano deploy.rb
set :repository, "git@bitbucket.org:repo/repo.git"
set :user, "deploy"
set :use_sudo, false
set :scm, :git
set :keep_releases, 5
set :domain, "000.000.000.000"
set :application, "my_app"
set :rails_env, "production"
set :branch, "master"
set :deploy_to, "/var/www/#{application}"
@jtadeulopes
jtadeulopes / semaphore-es.sh
Last active October 4, 2017 23:17 — forked from BlackFoks/semaphore-es.sh
A script for installing ES on SemaphoreCI
#!/bin/bash
# Install a custom ElasticSearch version - https://www.elastic.co/products/elasticsearch
#
# To run this script on SemaphoreCI, add the following command to your project's build setup:
# \curl -sSL <RAW_URL_FOR_THIS_SCRIPT> | bash -s
#
ELASTICSEARCH_VERSION="2.4.6"
ELASTICSEARCH_PORT="9250"
ELASTICSEARCH_DIR="$SEMAPHORE_PROJECT_DIR/elasticsearch"
ELASTICSEARCH_WAIT_TIME="15"