blob: 840aed047b3b78c6bf400d2ab2157580b6e393f1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# Guestbook
Standalone guestbook server meant to be paired up with a static website.
# Usage
## Configuration
Edit `/etc/guestbook.toml`
```toml
# the idea is to have a single database but different
# tables for each guestbook (if any)
[database]
# Supported - MySQL/MariaDB
username = "guestbook"
password = "guestbookpass"
location = "tcp(127.0.0.1:3306)"
db_name = "guestbook"
params = "charset=utf8mb4&parseTime=True&loc=Local"
# add as many as you like
# avoid having hyphens in the name
[my_guestbook]
port = 2222
path = "/sign"
validation_string = ""
success_redirect = "/success"
error_redirect = "/error"
template = """
{{range .}}
{{print "{{"}}
guestbook_entry(
name=\"{{.Name}}\",
website=\"{{.Website}}\",
message=\"{{.Message}}\",
time=\"{{.Time}}\"
)
{{print "}}"}}
{{end}}"""
```
## Starting with Systemd
Then use this Systemd service:
`/etc/systemd/system/my_guestbook-guestbook.service`
Replace `my_guestbook` with your guestbook's name (as defined in `/etc/guestbook.toml`),
create more `.service` files for as many guestbooks you want to have.
```
[Unit]
Description=Guestbook for my_guestbook
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=on-failure
RestartSec=1
ExecStart=guestbook --guestbook my_guestbook
[Install]
WantedBy=multi-user.target
```
Then, reload the daemon and start the guestbook:
```fish
systemctl daemon-reload
systemctl enable --now my_guestbook-guestbook
```
## Nginx configuration
Pass exactly the desired url to the guestbook server.
Replace port and the path to match your configuration.
```
location = /guestbook/sign {
proxy_pass http://localhost:2222/sign;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
```
## Reading entries
```fish
guestbook dump -g my_guestbook
```
## Licence
Licenced under GNU General Public Licence
GNU GPL License: [LICENSE](LICENSE)
Copyright (c) 2025 Vidhu Kant Sharma
|