Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community-containers - add caddy #3460

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .github/workflows/json-validator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ jobs:
sudo apt-get update
sudo apt-get install python3-pip -y --no-install-recommends
sudo pip3 install json-spec
json validate --schema-file=php/containers-schema.json --document-file=php/containers.json
if ! json validate --schema-file=php/containers-schema.json --document-file=php/containers.json; then
exit 1
fi
JSON_FILES="$(find ./community-containers -name '*.json')"
mapfile -t JSON_FILES <<< "$JSON_FILES"
for file in "${JSON_FILES[@]}"; do
json validate --schema-file=php/containers-schema.json --document-file="$file" | tee -a ./json-validator.log
json validate --schema-file=php/containers-schema.json --document-file="$file" 2>&1 | tee -a ./json-validator.log
done
if grep "Exception: document does not validate with schema." ./json-validator.log; then
if grep -q "document does not validate with schema." ./json-validator.log; then
exit 1
fi
51 changes: 51 additions & 0 deletions community-containers/caddy/caddy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"aio_services_v1": [
{
"container_name": "nextcloud-aio-caddy",
"display_name": "Caddy with geoblocking",
"image": "szaimen/aio-caddy",
"image_tag": "v1",
"internal_port": "443",
"restart": "unless-stopped",
"ports": [
{
"ip_binding": "",
"port_number": "443",
"protocol": "tcp"
},
{
"ip_binding": "",
"port_number": "443",
"protocol": "udp"
}
],
"environment": [
"TZ=%TIMEZONE%",
"NC_DOMAIN=%NC_DOMAIN%",
"APACHE_PORT=%APACHE_PORT%"
],
"volumes": [
{
"source": "nextcloud_aio_caddy",
"destination": "/data",
"writeable": true
},
{
"source": "%NEXTCLOUD_DATADIR%",
"destination": "/nextcloud",
"writeable": false
}
],
"aio_variables": [
"apache_ip_binding=127.0.0.1",
"apache_port=11000"
],
"nextcloud_exec_commands": [
"mkdir '/mnt/ncdata/admin/files/nextcloud-aio-caddy'",
"touch '/mnt/ncdata/admin/files/nextcloud-aio-caddy/allowed-countries.txt'",
"echo 'Scanning nextcloud-aio-caddy folder for admin user...'",
"php /var/www/html/occ files:scan --path='/admin/files/nextcloud-aio-caddy'"
]
}
]
}
14 changes: 14 additions & 0 deletions community-containers/caddy/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Caddy with geoblocking
This container bundles caddy and auto-configures it for you. It also covers https://github.com/nextcloud/all-in-one/tree/main/community-containers/vaultwarden by listening on `bw.$NC_DOMAIN`, if installed.

### Notes
- Make sure that no other service is using port 443 on your host as otherwise the containers will fail to start. You can check this with `sudo netstat -tulpn | grep 443` before installing AIO.
- Make sure that you point `bw.your-nc-domain.com` to your server using a cname record so that caddy can get a certificate automatically for vaultwarden.
- After the container was started the first time, you should see a new `nextcloud-aio-caddy` folder and inside there an `allowed-countries.txt` file when you open the files app with the default `admin` user. In there you can adjust the allowed country codes for caddy by adding them to the first line, e.g. `IT FR` would allow access from italy and france. Private ip-ranges are always allowed. Additionally, in order to activate this config, you need to get an account at https://dev.maxmind.com/geoip/geolite2-free-geolocation-data and download the `GeoLite2-Country.mmdb` and upload it with this exact name into the `nextcloud-aio-caddy` folder. Afterwards restart all containers from the AIO interface and your new config should be active!
- See https://github.com/nextcloud/all-in-one/tree/main/community-containers how to add it to the AIO stack

### Repository
https://github.com/szaimen/aio-caddy

### Maintainer
https://github.com/szaimen
4 changes: 2 additions & 2 deletions php/containers-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Z_-a-z]+=.*$"
"pattern": "^[A-Z_a-z-]+=.*$"
}
},
"restart": {
Expand Down Expand Up @@ -129,7 +129,7 @@
"type": "array",
"items": {
"type": "string",
"pattern": "^(php /var/www/html/occ .*|echo .*)$"
"pattern": "^(php /var/www/html/occ .*|echo .*|touch .*|mkdir .*)$"
}
},
"profiles": {
Expand Down