https://github.com/islamic-network/cdn
CDN Setup
https://github.com/islamic-network/cdn
cdn cdn-distribution nginx-docker
Last synced: 11 months ago
JSON representation
CDN Setup
- Host: GitHub
- URL: https://github.com/islamic-network/cdn
- Owner: islamic-network
- Created: 2021-07-18T18:55:50.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-14T09:15:30.000Z (almost 2 years ago)
- Last Synced: 2024-08-14T10:37:46.867Z (almost 2 years ago)
- Topics: cdn, cdn-distribution, nginx-docker
- Language: Shell
- Size: 145 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Islamic Network CDN
This is the harness used for the Islamic Network CDN. It's effectively ready to be used by anyone who wants to build a CDN.
It contains 3 directories:
* nginx - This directory contains all the NGINX and Docker configuration for the CDN
warranted.
* info - This is purely informational and has files that are linked from outside of this repo and the CDN. It's not really related to the CDN setup,
but relevant for users who consume assets on the Islamic Network CDN.
* purge - This directory triggers the pipeline to actually purge the cache from all the PoPs. Just update the paths.txt file's first line with what needs to be purged.
Many thanks to https://github.com/perusio/nginx-cache-purge for this script.
## Notes
### Purging cache
To purge a file:
```
docker exec -it islamic-network-cdn ./purge /quran/audio-surah/128/ar.alafasy/1.mp3 /var/cache/cdn
```
To purge a directory / path:
```
docker exec -it islamic-network-cdn ./purge /quran/audio-surah/128/ar.alafasy /var/cache/cdn
```
### Uploading files to an s3 bucket (this is a sample for 1 region)
```
s3cmd -c ~/.s3cfg_in_us --recursive --force --acl-public --add-header="Cache-Control: public, max-age=2628000" --add-header="expires: access plus 30 days" put /local/src/* s3://cdn.islamic.network/quran/audio/
```
### Generating Certificates on the first node
Install acme.sh:
```
wget -O - https://get.acme.sh | bash; source ~/.bashrc
```
Then generate the certificates:
```
acme.sh --issue --dns dns_cf -d cdn.islamic.network \
-d cdn.helsinki.islamic.network \
-d cdn.falkenstein.islamic.network \
-d cdn.singapore.islamic.network \
-d cdn.london.islamic.network \
-d cdn.mumbai.islamic.network \
-d cdn.newark.islamic.network \
-d cdn.dallas.islamic.network \
-d cdn.dubai.islamic.network \
-d cdn.aladhan.com \
--reloadcmd "docker exec -it islamic-network-cdn nginx -s reload"
```
These then need to be copied to all the other nodes via a monthly cronjob. This cron should be configured on the primary host for every PoP:
```
scp -r -P XXXXX /root/.acme.sh/cdn.islamic.network/* root@cdn.mumbai.islamic.network:/root/.acme.sh/cdn.islamic.network/ && ssh -t root@cdn.mumbai.islamic.network -p XXXXX "docker exec -it islamic-network-cdn nginx -s reload"
```
# Nodes that are not built and deployed via this repo:
* Helsinki
* Falkenstein