ethankhall / gadget-rust

Rusty "Go Links"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gadget

Gadget is a link shortener.

So you can do something like gto.cx/google and it will take you to duckduckgo.com. ;-)

There is an expression language that can be used for things like gto.cx/google this is a long query

Private Deployment

These steps are how to run Gadget inside a house, where there will be no public internet access.

While gadget could handle public internet access, you'll want things like TLS and auth when trying to access the configuration pages.

Systemd Unit File

This systemd file will keep the service up and running using docker.

# /etc/systemd/system/gadget-service.service
[Unit]
Description=Gadget Service Container
After=docker.service
Requires=docker.service

[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker stop gadget-service
ExecStartPre=-/usr/bin/docker rm gadget-service
ExecStart=/usr/bin/docker run \
    --rm \
    --name gadget-service \
    -v /mnt/<path to config dir>/gadget/:/opt/gadget/ \
    -p 8080:8080 \
    docker.pkg.github.com/ethankhall/gadget-rust/gadget:latest \
    /app/bin/gadget --database-url file:///opt/gadget/config.json


[Install]
WantedBy=multi-user.target

Deploy to the Public Internet

Follow the same steps for a private deployment and add the caddy configuration.

Caddy configuration

Caddy has some excellent documentation for how to set it up.

The following file will give a reasonabaly secure public internet deployment. This is a simple config, and could be made way more complete/ready for large scale deployment when adding auth.

#/etc/caddy/Caddyfile

example.com { 
        proxy / localhost:8080 {
            transparent
        }

        jwt {
            path /_gadget
            redirect /login?backTo={rewrite_uri}
            allow sub bob
        }

        login {
            simple bob=password
        }
}

About

Rusty "Go Links"


Languages

Language:Rust 90.2%Language:Dockerfile 6.2%Language:PLpgSQL 1.9%Language:HTML 1.5%Language:Shell 0.2%