Last active
June 11, 2016 20:34
-
-
Save jaimerodas/f3b4e70f438f9b395f8dd09d025c2485 to your computer and use it in GitHub Desktop.
Set up Ubuntu 14.04 con Digital Ocean
This file contains hidden or 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
upstream app { | |
server 127.0.0.1:3000 fail_timeout=0; | |
} | |
server { | |
listen 443 ssl; | |
server_name example.com www.example.com; | |
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_prefer_server_ciphers on; | |
ssl_dhparam /etc/ssl/certs/dhparam.pem; | |
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; | |
ssl_session_timeout 1d; | |
ssl_session_cache shared:SSL:50m; | |
ssl_stapling on; | |
ssl_stapling_verify on; | |
add_header Strict-Transport-Security max-age=15768000; | |
root /path/to/railsapp/public; | |
try_files $uri/index.html $uri @app; | |
location @app { | |
proxy_pass http://app; | |
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; | |
proxy_set_header Accept-Encoding ""; | |
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-Proto $scheme; | |
add_header Front-End-Https on; | |
proxy_redirect off; | |
} | |
error_page 500 502 503 504 /500.html; | |
client_max_body_size 4G; | |
keepalive_timeout 10; | |
} | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name example.com www.example.com; | |
location '/.well-known/acme-challenge' { | |
default_type "text/plain"; | |
root /tmp/letsencrypt-auto; | |
} | |
location / { | |
return 301 https://$server_name$request_uri; | |
} | |
} |
This file contains hidden or 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
# Aventuras en Setupear Ubuntu 14.04 en DO | |
# Para arreglar el pedo de locales, sigue las instrucciones de: | |
# http://www.pixelninja.me/how-to-fix-invalid-locale-setting-in-ubuntu-14-04-in-the-cloud/ | |
# que básicamente dice que agregues cosas a /etc/environment | |
echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale | |
# Actualizamos paquetes | |
apt-get update # porque ya somos sudo | |
# Creamos un usuario nuestro | |
# Que tenga sudo privileges | |
adduser --ingroup sudo jaime | |
gpasswd -a jaime sudo | |
# Nos pasamos al usuario | |
su - jaime | |
mkdir .ssh | |
chmod 700 .ssh | |
vim .ssh/authorized_keys | |
sudo vim /etc/ssh/sshd_config | |
# Hay que quitar PermitRootLogin | |
# Ya hecho eso, reiniciamos ssh | |
# SOLO HAZ ESTO SI YA JALA SUPER BIEN EL USUARIO NUEVO | |
sudo service ssh restart | |
# Pegas la llave pública y listo | |
# Después restringimos acceso a ese archivo | |
chmod 600 .ssh/authorized_keys | |
# Ya con eso podemos salir y entrar como el nuevo usuario | |
# Vamos a setupear el firewall | |
sudo ufw allow ssh | |
sudo ufw enable | |
# Setupeamos Time Zones | |
sudo dpkg-reconfigure tzdata | |
# Setupeamos NTP | |
sudo apt-get install ntp | |
# Setupeamos cosas básicas | |
sudo apt-get install git build-essential | |
# Setupeamos bash chido | |
sudo apt-get install zsh | |
zsh | |
chsh -s `which zsh` | |
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" |
This file contains hidden or 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
# Vamos a ver cómo se instala MySQL bien | |
sudo apt-get update | |
# Bajamos la última versión del apt de | |
# http://dev.mysql.com/downloads/repo/apt/ | |
wget http://dev.mysql.com/get/mysql-apt-config_0.7.2-1_all.deb | |
sudo dpkg -i mysql-apt-config_0.7.2-1_all.deb | |
# Ya que instalamos el apt, actualizamos e instalamos | |
sudo apt-get update | |
sudo apt-get install mysql-server | |
# Archivos Importantes: | |
# /etc/init.d/mysql (init script) | |
# /etc/mysql/my.cnf (config) | |
# Ahora sí, configuremos esta mamada | |
sudo mysql_secure_installation | |
# No necesitamos VALIDATE_PASSWORD porque vamos a usar passwords chidos, no? NO? | |
# Incluso, ya habíamos puesto un root password chido, así que tampoco lo tenemos que cambiar | |
# Quitamos anonymous users | |
# Quitamos remote login | |
# Quitamos test db | |
# Reloadeamos priviledge tables | |
# Hay que dejar que pasen las conexiones por el firewall | |
# podemos checar qué servicios hay en /etc/services | |
sudo ufw allow mysql | |
This file contains hidden or 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
# Para instalar rbenv | |
git clone https://github.com/rbenv/rbenv.git ~/.rbenv | |
cd ~/.rbenv && src/configure && make -C src | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc | |
~/.rbenv/bin/rbenv init | |
echo 'eval "$(rbenv init -)"' >> ~/.zshrc | |
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build | |
# Salir y entrar al shell | |
sudo apt-get install -y libssl-dev libreadline-dev zlib1g-dev | |
rbenv install 2.3.0 | |
rbenv global 2.3.0 | |
# Como estamos usando mysql, hay que hacer lo mismo que arriba | |
wget http://dev.mysql.com/get/mysql-apt-config_0.7.2-1_all.deb | |
sudo dpkg -i mysql-apt-config_0.7.2-1_all.deb | |
sudo apt-get update | |
# cosas necesarias para correr rails | |
sudo apt-get install libmysqlclient-dev nodejs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment