This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rack::Attack | |
# se um IP estiver fazendo uma série de requests, ele provavelmente | |
# é malicioso. então não vamos deixar ele derrubar nossa CPU | |
throttle('req/ip', limit: 300, period: 5.minutes) do |req| | |
req.ip | |
end | |
# o caso mais comum talvez seja o de forçar o login com uma série de | |
# logins e senhas até encontrar algum que bata |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini; | |
passenger_ruby /home/deploy/.rbenv/shims/ruby; # If you use rbenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# o nginx precisa de um certificado para ser instalado, | |
# com esse comando adicionamos o certificado | |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7 | |
sudo apt-get install -y apt-transport-https ca-certificates | |
# adiciona o repositório do passenger, necessário para | |
# rodar apps rails no nginx | |
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main > /etc/apt/sources.list.d/passenger.list' | |
sudo apt-get update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/puma.rb | |
threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 6) | |
workers Integer(ENV['WORKERS'] || 2) | |
port ENV['PORT'] || 3000 | |
environment ENV['RAILS_ENV'] || 'development' | |
preload_app! | |
on_worker_boot do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# uninstall postgresql if necessary | |
$ sudo pacman -R postgresql postgresql-libs | |
# remove postgres files | |
$ sudo rm -rfv /var/lib/postgres | |
# proceed with the installation | |
$ sudo pacman -S postgresql postgresql-libs | |
# setup password for postgres | |
$ sudo passwd postgres |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80 default_server; | |
server_name IP_DO_SEU_VPS; | |
root /home/beer/beer_on_rails/public; | |
passenger_enabled on; | |
rails_env production; | |
# responsável por carregar os assets | |
location ^~ /assets/ { |