Skip to content

Instantly share code, notes, and snippets.

View edinsoncs's full-sized avatar
🤖
Working from home

Edinson CS edinsoncs

🤖
Working from home
View GitHub Profile
@edinsoncs
edinsoncs / README.md
Created September 4, 2016 18:27 — forked from renchap/README.md
One-line certificate generation/renews with Letsencrypt and nginx

Prerequisites : the letsencrypt CLI tool

This method allows your to generate and renew your Lets Encrypt certificates with 1 command. This is easily automatable to renew each 60 days, as advised.

You need nginx to answer on port 80 on all the domains you want a certificate for. Then you need to serve the challenge used by letsencrypt on /.well-known/acme-challenge. Then we invoke the letsencrypt command, telling the tool to write the challenge files in the directory we used as a root in the nginx configuration.

I redirect all HTTP requests on HTTPS, so my nginx config looks like :

server {
//Empezar a utilizar Ecmnascript con use strict
'use strict';
let fs = require('fs');
fs
.rename('new', 'folder', (err) => {
if(err){
return err;
} else {
@edinsoncs
edinsoncs / nginxproxy.md
Created August 1, 2016 04:44 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@edinsoncs
edinsoncs / app.js
Created July 26, 2016 06:03 — forked from bingeboy/app.js
Upload and display image with NodeJS and Express.
/*
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, user = require('./routes/user')
, common = require('./routes/common')
, fs = require('fs')
, http = require('http')
, util = require('util')
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Javascript orientate objects</title>
</head>
<body>
<script>
/**
* @variables
*/
var thisName = prompt('Restaurante: Ingrese su nombre');
var thisCupon = "Aplicando Cupón...";
var thisEatMenu = ['Arroz', 'Pollo', 'Vegetales', 'Salsa'];
/**
* Send a data.
@edinsoncs
edinsoncs / Secure Sessions Howto
Created June 12, 2016 03:36 — forked from nikmartin/A: Secure Sessions Howto
Secure sessions with Node.js, Connect, and Nginx as an SSL Proxy
Secure sessions are easy, but it's not very well documented, so I'm changing that.
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy:
The desired configuration for using NginX as an SSL proxy is to offload SSL processing
and to put a hardened web server in front of your Node.js application, like:
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [CLIENT]
To do this, here's what you need to do:
@edinsoncs
edinsoncs / gist:4c67347c57dee241476aceff37550861
Created June 11, 2016 20:02 — forked from learncodeacademy/gist:ebba574fc3f438c851ae
Nginx Node Frontend / Load Balancer / Static Assets Caching
upstream project {
server 22.22.22.2:3000;
server 22.22.22.3:3000;
server 22.22.22.5:3000;
}
server {
listen 80;
location / {