-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version v1.0.0-alpha1 released; Better docs; changed defaults folder
- Loading branch information
Showing
6 changed files
with
33 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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 | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]> | ||
|
@@ -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 |