Skip to content

Commit

Permalink
Version v1.0.0-alpha1 released; Better docs; changed defaults folder
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Jul 10, 2016
1 parent 4303c27 commit 841caf8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 20 deletions.
43 changes: 28 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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
Expand All @@ -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
Expand All @@ -45,7 +58,7 @@ Connection: keep-alive
## @todo

- Implement SSL
- Implement Crawler via proxies
- Implement Crawler via proxies (need more test)

## Troubleshot

Expand All @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions prepare-configurations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
# @author Emerson Rocha Luiz <[email protected]>
Expand Down Expand Up @@ -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
"$BASE"/configuration/_default/varnish/default.vcl

0 comments on commit 841caf8

Please sign in to comment.