Skip to content

Commit

Permalink
Documentation, Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas committed Mar 8, 2023
1 parent 4933351 commit d055fd8
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ COPY . /build
# Prepare assets
RUN yarn install --pure-lockfile --production && \
yarn cache clean && \
sed -i -r -e "s|'cssmin',\s?'cssrewrite'|'cssmin'|g" /build/powerdnsadmin/assets.py && \
sed -i -r -e "s|'cssmin',\s?'cssrewrite'|'rcssmin'|g" /build/powerdnsadmin/assets.py && \
flask assets build

RUN mv /build/powerdnsadmin/static /tmp/static && \
Expand Down
7 changes: 6 additions & 1 deletion docs/wiki/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- [Systemd + Gunicorn + Apache](web-server/Running-PowerDNS-Admin-with-Systemd,-Gunicorn-and-Apache.md)
- [uWSGI](web-server/uWSGI-example.md)
- [WSGI-Apache](web-server/WSGI-Apache-example.md)
- [Docker-ApacheReverseProxy](webserver/Running-Docker-Apache-Reverseproxy.md)

## Using PowerDNS-Admin

Expand All @@ -43,4 +44,8 @@

## Feature usage

- [DynDNS2](features/DynDNS2.md)
- [DynDNS2](features/DynDNS2.md)

## Debugging

- [Debugging the build process](debug/build-process.md)
61 changes: 61 additions & 0 deletions docs/wiki/debug/build-process.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
This discribes how to debug the buildprocess


docker-compose.yml

```
version: "3"
services:
app:
image: powerdns/custom
container_name: powerdns
restart: always
build:
context: git
dockerfile: docker/Dockerfile
network_mode: "host"
logging:
driver: json-file
options:
max-size: 50m
environment:
- BIND_ADDRESS=127.0.0.1:8082
- SECRET_KEY='VerySecret'
- SQLALCHEMY_DATABASE_URI=mysql://pdnsadminuser:[email protected]/powerdnsadmin
- GUNICORN_TIMEOUT=60
- GUNICORN_WORKERS=2
- GUNICORN_LOGLEVEL=DEBUG
- OFFLINE_MODE=False
- CSRF_COOKIE_SECURE=False
```

Create a git folder in the location of the `docker-compose.yml` and clone the repo into it

```
mkdir git
cd git
git clone https://github.com/PowerDNS-Admin/PowerDNS-Admin.git .
```

In case you are behind an SSL Filter like me, you can add the following to each stage of the `git/docker/Dockerfile`

This installs the command `update-ca-certificates` from the alpine repo and adds an ssl cert to the trust chain, make sure you are getting the right version in case the base image version changes

```
RUN mkdir /tmp-pkg && cd /tmp-pkg && wget http://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/ca-certificates-20220614-r4.apk && apk add --allow-untrusted --no-network --no-cache /tmp-pkg/ca-certificates-20220614-r4.apk || true
RUN rm -rf /tmp/pkg
COPY MyCustomCerts.crt /usr/local/share/ca-certificates/MyCustomCerts.crt
RUN update-ca-certificates
COPY pip.conf /etc/pip.conf
```

`MyCustomCerts.crt` and `pip.conf` have to be placed inside the `git` folder.

The content of `pip.conf` is:

```
[global]
cert = /usr/local/share/ca-certificates/MyCustomCerts.crt
```

For easier debugging you can change the `CMD` of the `Dockerfile` to `CMD ["tail","-f", "/dev/null"]` though I expect you to be fluent in Docker in case you wish to debug
73 changes: 73 additions & 0 deletions docs/wiki/web-server/Running-Docker-Apache-Reverseproxy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
This describes how to run Apache2 on the host system with a reverse proxy directing to the docker container

This is usually used to add ssl certificates and prepend a subdirectory

The network_mode host settings is not neccessary but used for ldap availability in this case


docker-compose.yml

```
version: "3"
services:
app:
image: powerdnsadmin/pda-legacy:latest
container_name: powerdns
restart: always
network_mode: "host"
logging:
driver: json-file
options:
max-size: 50m
environment:
- BIND_ADDRESS=127.0.0.1:8082
- SECRET_KEY='NotVerySecret'
- SQLALCHEMY_DATABASE_URI=mysql://pdnsadminuser:[email protected]/powerdnsadmin
- GUNICORN_TIMEOUT=60
- GUNICORN_WORKERS=2
- GUNICORN_LOGLEVEL=DEBUG
- OFFLINE_MODE=False
- CSRF_COOKIE_SECURE=False
- SCRIPT_NAME=/powerdns
```

After running the Container create the static directory and populate

```
mkdir -p /var/www/powerdns
docker cp powerdns:/app/powerdnsadmin/static /var/www/powerdns/
chown -R root:www-data /var/www/powerdns
```

Adjust the static reference, static/assets/css has a hardcoded reference

```
sed -i 's/\/static/\/powerdns\/static/' /var/www/powerdns/static/assets/css/*
```

Apache Config:

You can set the SCRIPT_NAME environment using Apache as well, once is sufficient though

```
<Location /powerdns>
RequestHeader set X-Forwarded-Proto "https"
RequestHeader set X-Forwarded-Port "443"
RequestHeader set SCRIPT_NAME "/powerdns"
ProxyPreserveHost On
</Location>
ProxyPass /powerdns/static !
ProxyPass /powerdns http://127.0.0.1:8082/powerdns
ProxyPassReverse /powerdns http://127.0.0.1:8082/powerdns
Alias /powerdns/static "/var/www/powerdns/static"
<Directory "/var/www/powerdns/static">
Options None
#Options +Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
```
4 changes: 2 additions & 2 deletions powerdnsadmin/templates/admin_history.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ <h3 class="card-title">Activity Search</h3>

$(document).ready(function () {
$.ajax({
url: "/admin/history_table",
url: '{{ url_for("admin.history_table") }}',
type: "get",
success: function (response) {
console.log('Submission was successful.');
Expand Down Expand Up @@ -493,7 +493,7 @@ <h3 class="card-title">Activity Search</h3>
var form = $(this);
var tzoffset = (new Date()).getTimezoneOffset();
$.ajax({
url: "/admin/history_table",
url: '{{ url_for("admin.history_table") }}',
type: "get",
data: form.serialize() + "&tzoffset=" + tzoffset,
success: function (response) {
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ rjsmin==1.2.1
webcolors==1.12
werkzeug==2.1.2
zipp==3.11.0
rcssmin==1.1.1

0 comments on commit d055fd8

Please sign in to comment.