Skip to content

Instantly share code, notes, and snippets.

View Kikobeats's full-sized avatar
👋
say hi

Kiko Beats Kikobeats

👋
say hi
View GitHub Profile
@Kikobeats
Kikobeats / gist:8e87acf60db34ccd907a
Created October 8, 2014 08:31
NGINX con NodeJS
Buenas,
Sí, claro: puedes tener varias aplicaciones de Node.js en la misma máquina andando, escuchando cada una por su puerto, y necesitas un proxy inverso para que distribuya el juego según la ruta. Por ejemplo:
Una aplicación web (Node.js) que escucha por el puerto 9000.
Una aplicación de administración (Node.js) que escucha por el 9010.
Un API (Node.js) que escucha por el puerto 9020.
Y un nginx que escucha por el 80, y redirige /web al puerto 9000, /admin a 9010 y /api al 9020.
El proxy inverso tiene la ventaja de que filtra requests inválidas y protege en general contra posibles vulnerabilidades en Node.js. Además, es mucho más fácil hacer keep-alive desde Node.js si todas las peticiones vienen del mismo proceso, con lo que el rendimiento es mejor.
Y, ¿qué mejor proxy inverso que nginx? Pues ahora que lo dices... Yo últimamente uso HAProxy que está pensado específicamente para hacer de proxy inverso. La configuración queda mucho más sencilla y se puede configurar un pool de máquinas, el algoritmo de di
@Kikobeats
Kikobeats / update_all.sh
Created September 12, 2014 15:00
BASH Script for update a list of repositories
#!/bin/bash -x
welcome() {
echo " _ _____________ ___ _____ _____ "
echo "| | | | ___ \ _ \/ _ \_ _| ___|"
echo "| | | | |_/ / | | / /_\ \| | | |__ "
echo "| | | | __/| | | | _ || | | __| "
echo "| |_| | | | |/ /| | | || | | |___ "
echo " \___/\_| |___/ \_| |_/\_/ \____/"
echo
<link rel="import" href="../components/polymer/polymer.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@Kikobeats
Kikobeats / CoffeeScript Class Orientation
Created July 22, 2014 11:01
CoffeeScript Class Orientation
### Constructor
### Static Variables
### Instance Variables
### Static Methods (use `=>`)
@static_method: =>
@Kikobeats
Kikobeats / system_fresh
Created June 24, 2014 14:47
Update System
#!/bin/bash
## Brew update
cd "$(brew --prefix)"
git fetch origin
git reset --hard origin/master
brew update
brew upgrade
brew cleanup
2014-01-27T00:47:46.606159+00:00 heroku[api]: Deploy a00bd0e by kikohumanbeatbox@gmail.com
2014-01-27T00:47:46.711233+00:00 heroku[api]: Release v5 created by kikohumanbeatbox@gmail.com
2014-01-27T00:47:46+00:00 heroku[slug-compiler]: Slug compilation finished
2014-01-27T00:47:47.236486+00:00 heroku[web.1]: State changed from crashed to starting
2014-01-27T00:47:49.498777+00:00 heroku[web.1]: Starting process with command `node yoi.js`
2014-01-27T00:47:50.408610+00:00 app[web.1]: Direct yaml files load via require() is deprecated! Use safeLoad() instead.
2014-01-27T00:47:51.940885+00:00 app[web.1]:
================================================================================
2014-01-27T00:47:51.941120+00:00 app[web.1]: YOI v0.10.03
2014-01-27T00:47:51.941120+00:00 app[web.1]: Easy (but powerful) NodeJS server
{
"PHP": {
"php": '/usr/bin/php',
"phpExtraPaths": [],
"phpConfigFile": 'php.ini'
},
"JavaScript": {
"javascriptExtraPaths": []
},
"Perl": {
<!-- Apple Full-Screen WebApp Options -->
<!-- Do NOT use width=device width because it will letterbox viewport. -->
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- yes or not for fullscreen mode -->
<meta name="apple-mobile-web-app-capable" content="yes">
<!-- Only if full screen is activate. Can be "default, black or black-translucent -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">