From 841caf8ee6f7c3ec38054028065b36f572ab6f3c Mon Sep 17 00:00:00 2001 From: Emerson Rocha Luiz Date: Sun, 10 Jul 2016 05:29:44 -0300 Subject: [PATCH] Version v1.0.0-alpha1 released; Better docs; changed defaults folder --- README.md | 43 ++++++++++++------- .../crawler/configuration.json | 0 .../nginx/conf.d/default.conf | 0 .../{default => _default}/nginx/nginx.conf | 0 .../{default => _default}/varnish/default.vcl | 0 prepare-configurations.sh | 10 ++--- 6 files changed, 33 insertions(+), 20 deletions(-) rename configuration/{default => _default}/crawler/configuration.json (100%) rename configuration/{default => _default}/nginx/conf.d/default.conf (100%) rename configuration/{default => _default}/nginx/nginx.conf (100%) rename configuration/{default => _default}/varnish/default.vcl (100%) diff --git a/README.md b/README.md index 0559d14..086a5d1 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,39 @@ -# reverse-proxy-cdn +# Simple Reverse Proxy Content Delivery Network v1.0.0-alpha1 -Default ports: - -- 80, 433: nginx -- 8080: varnish -- 8888: nodeapp (crawler) +This is a very simple, but functional, Reverse Proxy with caching, that can be +used as your own [CDN](https://en.wikipedia.org/wiki/Content_delivery_network), +with good defaults that almost work out of the box. Uses +[docker](https://www.docker.com/). Quickstart: -``` +```bash +$ git clone git@github.com:alligo/reverse-proxy-cdn.git +$ cd reverse-proxy-cdn $ docker build -t alligo/reverse-proxy-cdn . -$ docker run --rm -p 80:80 -p 443:443 -p 8888:8888 -p 8080:8080 --ulimit memlock=9223372036854775807 --name mycdn alligo/reverse-proxy-cdn +$ docker run --rm -p 80:80 -p 443:443 --ulimit memlock=9223372036854775807 --name simplecdn alligo/reverse-proxy-cdn ``` -Debug: - docker exec -it mycdn bash +## How to customize and debug -Test to proxy http://cdn.fititnt.org/img/emerson-rocha-luiz.jpg +Just to keep it simple, this solution uses just one docker container instead of +make one container for NGinx, Varnish and the Crawler. + +Default configurations files are on folder [configuration/_default]. Any custom +change, just copy file from a path without _default, and make your changes. + +Debug: +```bash +$ docker exec -it simplecdn bash +$ docker run --rm -p 80:80 -p 443:443 -p 8888:8888 -p 8080:8080 --ulimit memlock=9223372036854775807 --name simplecdn alligo/reverse-proxy-cdn ``` + +Test to proxy http://cdn.fititnt.org/img/emerson-rocha-luiz.jpg + +```bash $ # Allow example -$ curl -I http://127.0.0.1:8888/http://cdn.fititnt.org/img/emerson-rocha-luiz.jpg +$ curl -I http://127.0.0.1/http://cdn.fititnt.org/img/emerson-rocha-luiz.jpg HTTP/1.1 200 OK date: Sun, 10 Jul 2016 06:24:14 GMT server: Apache @@ -35,7 +48,7 @@ content-type: image/jpeg $ # Deny example -$ curl -I http://127.0.0.1:8888/https://www.bcdonadio.com/images/me.jpg +$ curl -I http://127.0.0.1/https://www.bcdonadio.com/images/me.jpg HTTP/1.1 401 Unauthorized Content-Type: application/json Date: Sun, 10 Jul 2016 06:26:32 GMT @@ -45,7 +58,7 @@ Connection: keep-alive ## @todo - Implement SSL -- Implement Crawler via proxies +- Implement Crawler via proxies (need more test) ## Troubleshot @@ -58,7 +71,7 @@ Error: Solution: do on machine that runs docker -``` +```bash $ sudo su $ cat >> /etc/security/limits.conf <<-EOF docker hard memlock 82000 diff --git a/configuration/default/crawler/configuration.json b/configuration/_default/crawler/configuration.json similarity index 100% rename from configuration/default/crawler/configuration.json rename to configuration/_default/crawler/configuration.json diff --git a/configuration/default/nginx/conf.d/default.conf b/configuration/_default/nginx/conf.d/default.conf similarity index 100% rename from configuration/default/nginx/conf.d/default.conf rename to configuration/_default/nginx/conf.d/default.conf diff --git a/configuration/default/nginx/nginx.conf b/configuration/_default/nginx/nginx.conf similarity index 100% rename from configuration/default/nginx/nginx.conf rename to configuration/_default/nginx/nginx.conf diff --git a/configuration/default/varnish/default.vcl b/configuration/_default/varnish/default.vcl similarity index 100% rename from configuration/default/varnish/default.vcl rename to configuration/_default/varnish/default.vcl diff --git a/prepare-configurations.sh b/prepare-configurations.sh index 1343f9b..ddae890 100755 --- a/prepare-configurations.sh +++ b/prepare-configurations.sh @@ -3,7 +3,7 @@ # # @description Simple script to replace system file configurations # with defaults. Fist check for configuration/app -# files and, if does not have, will use configuration/default/app +# files and, if does not have, will use configuration/_default/app # # @author Bernardo Donadio # @author Emerson Rocha Luiz @@ -43,19 +43,19 @@ BASE=`pwd` replace_file_with_default \ "$BASE"/configuration.json \ "$BASE"/configuration/crawler/configuration.json \ - "$BASE"/configuration/default/crawler/configuration.json + "$BASE"/configuration/_default/crawler/configuration.json replace_file_with_default \ /etc/nginx/nginx.conf \ "$BASE"/configuration/nginx/nginx.conf \ - "$BASE"/configuration/default/nginx/nginx.conf + "$BASE"/configuration/_default/nginx/nginx.conf replace_file_with_default \ /etc/nginx/conf.d/default.conf \ "$BASE"/configuration/nginx/conf.d/default.conf \ - "$BASE"/configuration/default/nginx/conf.d/default.conf + "$BASE"/configuration/_default/nginx/conf.d/default.conf replace_file_with_default \ /etc/varnish/default.vcl \ "$BASE"/configuration/varnish/default.vcl \ - "$BASE"/configuration/default/varnish/default.vcl \ No newline at end of file + "$BASE"/configuration/_default/varnish/default.vcl \ No newline at end of file