readme and finishing touches
sophuwu sophie@skisiel.com
Fri, 20 Dec 2024 03:21:48 +0100
5 files changed,
115 insertions(+),
4 deletions(-)
M
.gitignore
→
.gitignore
@@ -1,6 +1,5 @@
build/ -webhome/*.sqlite webhome/*.db -webhome/media/* +webhome/media webhome/*.log webhome/userpass
A
README.md
@@ -0,0 +1,93 @@
+# MyWeb + +MyWeb is a simple web application for managing blog posts, media files, and animations. +It is built with Go and uses a bbolt + storm database for dynamic content. + +## Features + +- Blogs - A page for looking at blog descriptions to navigate to the full blog post. +- Media - Upload media files and automatically convert them to webp if possible. +- Animations - A page for displaying pictures and videos with short descriptions. +- Manage - A page for managing blog posts, media files, and animations. + +## Recommendations + +- Use a reverse proxy such as [Caddy](https://caddyserver.com/) to serve the application. +- Only listen on 127.0.0.1 or a local network address. +- Use a firewall to block all incoming traffic except for the reverse proxy. + +## Installation + +1. Set up configuration: + - Edit the webhome/myweb.conf file. + - Set the URL, maintainer name, and email. + - Set the listen ip or port if needed. + ```sh + nano webhome/myweb.conf + ``` + +2. Make a bcrypt password for the admin user: + - Run the following command to create a password hash. + - Replace "username" and "password" with your desired admin username and password. + ```sh + name="username" \ + pass="password" \ + caddy hash-password --plaintext="$name:$pass" > webhome/userpass + ``` + - You can also use another implementation of bcrypt to create the password hash. + - Format the file as `hash` where hash is the hash of the string "username:password". + +3. Copy the webhome directory to your http user directory: + ```sh + # Copy files to http user directory. Use the actual user name for httpuser on your system. + sudo cp -r ./webhome ~httpuser/ + # Change the owner of directory only, so the server can create new files. + sudo chown httpuser ~httpuser/myweb + ``` + +4. Build the application: + ```sh + go build -ldflags="-w -s" -trimpath -o build/ + ``` + +5. Install the application: + ```sh + sudo install ./build/myweb /usr/local/bin/myweb + ``` + +## Systemd Service + +1. Edit the service file: + - Edit the `myweb.service` file. + - Change the User to the user that your web server runs as. + - Change the WorkingDirectory to the directory where you copied the webhome directory. + - Change the ExecStart to the path where you installed the application if different. + +2. Install the systemd service: + ```sh + sudo install ./myweb.service /etc/systemd/system/myweb.service + ``` + +3. Start the service: + ```sh + sudo systemctl start myweb + sudo systemctl enable myweb + sudo systemctl status myweb + ``` + +## Run from Command Line + +```sh + myweb /path/to/myweb.conf +``` + +## Manage Content + +1. Log in to the manage page: + - Go to the manage page at `/manage/`. + - Log in with the username and password you created earlier. + - Select management options from the menu. + +## License + +This project is licensed under the MIT License.
A
myweb.service
@@ -0,0 +1,19 @@
+[Unit] +Description=MyWeb Service +After=network.target + +[Service] +# Set this to where you copied the webhome directory +WorkingDirectory=/home/httpuser/webhome + +# Set this to the binary you built +ExecStart=/usr/local/bin/myweb + +# Set this to the user you want to run as (e.g. httpuser) +User=httpuser + + +Restart=always + +[Install] +WantedBy=multi-user.target
M
webhome/myweb.conf
→
webhome/myweb.conf
@@ -2,8 +2,7 @@ ## The port to listen for http requests.
port=8085 ## The address to listen for http requests. -address=0.0.0.0 - +address=127.0.0.1 ## The path to the directory containing the website files. ## Absolute or relative to the directory containing this file. webroot=./