2022-06-30 10:53:43 +02:00
---
title: Hedgedoc
2022-11-19 15:25:20 +01:00
visible: true
2022-06-30 10:53:43 +02:00
---
[toc]
2022-12-16 11:50:40 +01:00
2022-06-30 10:57:06 +02:00
## Podman
2022-12-16 11:50:40 +01:00
2022-06-30 10:57:06 +02:00
### Network and Pod
2022-12-16 11:50:40 +01:00
2023-02-23 14:48:51 +01:00
```sh
podman network create net_hedgedoc
podman pod create --name pod_hedgedoc --network net_hedgedoc -p 127.0.0.1:5432:5432 -p 3005:3000
```
2022-06-30 10:53:43 +02:00
2022-06-30 10:57:06 +02:00
### Database
2022-12-16 11:50:40 +01:00
```sh
2022-06-30 10:53:43 +02:00
# podman run --name hedgedocdb \
-e POSTGRES_PASSWORD=hedgedoc \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-v /mnt/postgres:/var/lib/postgresql/data \
--pod pod_hedgedoc \
2022-11-20 18:51:22 +01:00
-d docker.io/postgres:14
2022-06-30 10:53:43 +02:00
```
2022-12-16 11:50:40 +01:00
2023-02-23 14:48:51 +01:00
```sh
podman exec -it hedgedocdb bash
psql -U postgres
```
Create database used by hedgedoc
2022-06-30 10:53:43 +02:00
2023-02-23 14:48:51 +01:00
```sql
CREATE DATABASE hedgedocdb;
```
2022-06-30 10:53:43 +02:00
2022-06-30 10:57:06 +02:00
### Application
2022-12-16 11:50:40 +01:00
```sh
2022-06-30 10:53:43 +02:00
# podman run -d --name hedgedoc \
-e CMD_DB_URL=postgres://postgres:hedgedoc@localhost:5432/hedgedocdb \
2022-06-30 10:55:11 +02:00
-e CMD_DOMAIN=(url) \
-e CMD_PROTOCOL_USESSL=true \
-e CMD_ALLOW_ANONYMOUS=false \
-e CMD_ALLOW_ANONYMOUS_EDITS=true \
-e CMD_DEFAULT_PERMISSION=private \
-e CMD_ALLOW_EMAIL_REGISTER=false \
-v /mnt/hedgedoc:/hedgedoc/public/uploads \
--pod pod_hedgedoc \
2022-06-30 10:53:43 +02:00
quay.io/hedgedoc/hedgedoc:latest
```
2022-12-16 11:50:40 +01:00
2022-06-30 10:57:21 +02:00
## Create user
2022-12-16 11:50:40 +01:00
Because `CMD_ALLOW_EMAIL_REGISTER` is set to `false` , registration of new users has to be done through the CLI interface using `bin/manage_users` in the container.
2022-06-30 10:53:43 +02:00
2023-02-23 14:48:51 +01:00
```sh
podman exec -it hedgedocdb bash
bin/manage_users --add (email)
```
2022-06-30 10:53:43 +02:00
2022-06-30 10:54:01 +02:00
## Nginx config
2022-12-16 11:50:40 +01:00
```nginx
2022-06-30 10:53:43 +02:00
server {
server_name SERVER_NAME;
# Security / XSS Mitigation Headers
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
location / {
# Proxy main traffic
proxy_pass http://(SERVER);
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Forwarded-Host $http_host;
}
2022-12-16 11:50:40 +01:00
2022-06-30 10:53:43 +02:00
location /socket.io/ {
proxy_pass http://(SERVER);
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Forwarded-Host $http_host;
}
listen *:443 ssl http2;
ssl_certificate_key /etc/acme-sh/SERVER_NAME/key.pem;
ssl_certificate /etc/acme-sh/SERVER_NAME/cert.pem;
}
server {
if ($host = SERVER_NAME) {
return 301 https://$host$request_uri;
}
listen *:80;
server_name SERVER_NAME;
return 404;
}
2022-11-19 15:25:20 +01:00
```