Skip to content
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ You can execute `docker-compose up -d --build --force-recreate` to start and bui

It is possible to adapt the `pretixuser` crontab entries by modifying the [crontab](docker/pretix/crontab.bak) file.

## TLS setup

You can specify the used TLS certificates by adapting the mounted [certificate](docker/pretix/files/config/ssl/domain.crt) and [key](docker/pretix/files/config/ssl/domain.key) e.g. from LetsEncrypt or generating new self-signed certificates by following the [manual](scripts/EXAMPLE-CERT-CREATION.md) and moving the generated files.

## Contribution
If you would like to contribute something, have an improvement request, or want to make a change inside the code, please open a pull request.

Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ services:
volumes:
- pretix_data:/data
- ./docker/pretix/pretix.cfg:/etc/pretix/pretix.cfg
- ./docker/pretix/nginx/nginx.conf:/etc/nginx/nginx.conf
- ./docker/pretix/crontab:/tmp/crontab
ports:
- "8000:80"
- "80:80"
- "443:443"
networks:
- backend

Expand Down
7 changes: 5 additions & 2 deletions docker/pretix/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ FROM pretix/standalone:stable

USER root

ENV IMAGE_CRON_DIR="/image/cron"
ENV IMAGE_CRON_DIR="/image/cron" \
IMAGE_CONFIG_DIR="/image/config"

ADD files /image
COPY crontab /tmp/crontab

RUN mv /image/supervisord/crond.conf /etc/supervisord/crond.conf && \
pip install crontab && chmod +x $IMAGE_CRON_DIR/cron.py
pip install crontab && chmod 644 $IMAGE_CONFIG_DIR/ssl/*.crt && chmod +x $IMAGE_CRON_DIR/cron.py

USER pretixuser

EXPOSE 443

ENTRYPOINT ["pretix"]
CMD ["all"]
Empty file.
Empty file.
Empty file.
89 changes: 89 additions & 0 deletions docker/pretix/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
user www-data www-data;
worker_processes auto;
pid /var/run/nginx.pid;
daemon off;
worker_rlimit_nofile 262144;

events {
worker_connections 16384;
multi_accept on;
use epoll;
}

http {
server_tokens off;
sendfile on;
charset utf-8;
tcp_nopush on;
tcp_nodelay on;

log_format private '[$time_local] $host "$request" $status $body_bytes_sent';

types_hash_max_size 2048;
server_names_hash_bucket_size 64;

include /etc/nginx/mime.types;
default_type application/octet-stream;
add_header X-Content-Type-Options nosniff;

access_log /var/log/nginx/access.log private;
error_log /var/log/nginx/error.log;
add_header Referrer-Policy same-origin;

gzip on;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml image/svg+xml;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;

include /etc/nginx/conf.d/*.conf;

server {
listen 80 backlog=4096 default_server;
listen [::]:80 ipv6only=on default_server;
listen 443 backlog=4096 default_server ssl;
listen [::]:443 ipv6only=on default_server ssl;
server_name _;
ssl_certificate /image/config/ssl/domain.crt;
ssl_certificate_key /image/config/ssl/domain.key;

index index.php index.html;
root /var/www;

location /media/ {
alias /data/media/;
expires 7d;
access_log off;
}
location ^~ /media/cachedfiles {
deny all;
return 404;
}
location ^~ /media/invoices {
deny all;
return 404;
}
location /static/ {
alias /pretix/src/pretix/static.dist/;
access_log off;
expires 365d;
add_header Cache-Control "public";
add_header Access-Control-Allow-Origin "*";
gzip on;
}
location / {
# Very important:
# proxy_pass http://unix:/tmp/pretix.sock:;
# is not the same as
# proxy_pass http://unix:/tmp/pretix.sock:/;
# In the latter case, nginx will apply its URL parsing, in the former it doesn't.
# There are situations in which pretix' API will deal with "file names" containing %2F%2F, which
# nginx will normalize to %2F, which can break ticket validation.
proxy_pass http://unix:/tmp/pretix.sock:;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
}
}
21 changes: 21 additions & 0 deletions scripts/EXAMPLE-CERT-CREATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Example of the cert creation for the Nginx setup

## Creation

Please execute the following script `bash create-tls-certs.sh` to create all necessary certificates for the complete setup of all related components.

## Adaptation

Please adjust the configuration files inside the [config](./config) folder and adapt the corresponding values for the req_distinguished_names and subjectAltNames based on your organisation and configuration. You can find [here](https://support.dnsimple.com/articles/what-is-common-name/) and [here](https://learn.microsoft.com/en-us/azure/application-gateway/self-signed-certificates) more information about the corresponding values and CA certificates in general.

## Ca Certificates

### Nginx

Describes the Certificate Authority (certificate & key) for the Nginx server.

## Server Certificates

### Nginx

Describes the server certificate and key for the Nginx server, and it's signed by the Nginx CA.
Empty file added scripts/certs/.placeholder
Empty file.
20 changes: 20 additions & 0 deletions scripts/config/ca_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[req]
distinguished_name = req_distinguished_name
default_bits = 4096
prompt = no
default_md = sha256

[req_distinguished_name]
C = DE
ST = Baden-Wuerttemberg
L = Mannheim
O = TheIOTStudio
CN = Pretix Nginx CA
emailAddress = info@theiotstudio.com

[ext]
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = critical, CA:TRUE, pathlen:3
keyUsage = critical, cRLSign, keyCertSign
nsCertType = sslCA, emailCA
19 changes: 19 additions & 0 deletions scripts/config/server_nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
default_bits = 4096
prompt = no
default_md = sha256

[req_distinguished_name]
C = DE
ST = Baden-Wuerttemberg
L = Mannheim
O = TheIOTStudio
CN = Pretix Nginx Server
emailAddress = info@theiotstudio.com

[v3_req]
keyUsage = keyEncipherment, dataEncipherment, digitalSignature
extendedKeyUsage = serverAuth, clientAuth
subjectAltName=IP:<IP address of the Nginx server> or DNS:<DNS address of the Nginx server>
18 changes: 18 additions & 0 deletions scripts/create-tls-certs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# Switch the directory
echo "Switch the directory"
path=$(pwd)/config
cd certs

# Create the Nginx ca
echo "Create the Nginx ca"
openssl req -new -x509 -sha256 -newkey rsa:4096 -nodes -keyout ca_nginx.key -out ca_nginx.crt -days 3650 \
-extensions ext \
-config $path/ca_nginx.conf

# Create the server certificates
echo "Create the Nginx server certificates"
openssl genrsa -out nginx.key 4096
openssl req -new -key nginx.key -out nginx.csr -extensions v3_req -config $path/server_nginx.conf
openssl x509 -inform pem -req -days 1825 -in nginx.csr -CA ca_nginx.crt -CAkey ca_nginx.key -CAcreateserial -out nginx.crt -extensions v3_req -extfile $path/server_nginx.conf