Skip to content

Instantly share code, notes, and snippets.

View purwandi's full-sized avatar
🏠
Working from home

purwandi purwandi

🏠
Working from home
View GitHub Profile
<!-- start: #main -->
<p></p>
<p></p>
<p><!-- start: .main-inner --></p>
<div class="main-inner"><!-- start: .section-header -->
<div class="section-header">
<div class="container">
<div class="row">
<div class="col-xs-12">
<h1 class="section-title">F.A.Q</h1>
@purwandi
purwandi / email.html
Created October 10, 2016 02:30
EMail
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css" rel="stylesheet" media="all">
/* Media Queries */
@media only screen and (max-width: 500px) {
@purwandi
purwandi / Controller.php
Created June 2, 2016 14:46
Custom error format response Lumen Framework
<?php
namespace App\Http\Controllers;
use Laravel\Lumen\Routing\Controller as BaseController;
class Controller extends BaseController
{
public function __construct()
{
@purwandi
purwandi / ApiMiddleware.php
Last active May 26, 2016 13:26
Laravel CORS
<?php
namespace App\Http\Middleware;
use Closure;
class ApiMiddleware
{
/**
* Handle an incoming request.
<?php
namespace App;
use Illuminate\Http\Request;
class FooController extends Controller
{
public function index(Request $request)
{
@purwandi
purwandi / README.md
Created May 24, 2016 17:28 — forked from dominikwilkowski/README.md
Ubuntu 16.04 setup with NGINX http/2 and letsencrypt

Intro

This is a basic collection of things I do when setting up a new headless ubuntu machine as a webserver. Following the steps below should give you a reasonable secure server with HTTP/2 support (including ALPN in chrome) and the fast NGINX server. I am happy to add things so leave a comment.

Basics

After creating the server (droplet on DigitalOcean) log in with

@purwandi
purwandi / letsencrypt.md
Created May 24, 2016 17:15 — forked from xrstf/letsencrypt.md
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

@purwandi
purwandi / README.md
Created May 24, 2016 16:40 — 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 {
@purwandi
purwandi / docker-cleanup.sh
Created April 22, 2016 02:07
Cleanup docker images
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
# find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf ( docker ps -aq | xargs docker inspect | jq -r '.[] | .Mounts | .[] | .Name | select(.)') | xargs -r rm -fr
FROM gliderlabs/alpine:3.3
RUN apk update \
&& apk add bash less vim nginx ca-certificates \
php-fpm php-json php-zlib php-xml php-pdo php-phar php-openssl \
php-pdo_mysql php-mysqli \
php-gd php-iconv php-mcrypt \
php-mysql php-curl php-opcache php-ctype php-apcu \
php-intl php-bcmath php-dom php-xmlreader mysql-client && apk add -u musl