Skip to content

Deploy on your local machine

The application can be deployed locally as a compute-local forwarder, similar to the GoLinks project. To do this:

  1. Build the application

    task bin/all
    
  2. Move it to a suitable directory

    mv dist/linux+<architecture>/x40.link /usr/local/bin/
    
  3. Write some URLs to a place that the application can read

    mkdir -p /etc/x40.link
    cat <<'EOF'>> /etc/x40.link/urls.yaml
    ---
    - from: //x40/foo
      to: //k3s/bar
    - from: //x40/bar
      to: //k3s/baz
    EOF
    
  4. Enable the binary to bind ports lower than 1024 without needing root privileges (Linux Only)

    setcap 'cap_net_bind_service=+ep' /usr/local/bin/x40.link
    
  5. Create a systemd unit to manage the application

    cat <<'EOF' > /etc/systemd/system/x40.link.service
    [Unit]
    Description="The @link Shortener"
    After=network-online.target
    
    [Service]
    ExecStart=/usr/local/bin/x40.link serve --with-yaml /etc/x40.link/urls.yaml
    
    [Install]
    WantedBy=multi-user.target
    EOF
    
  6. Reload systemd

    systemctl daemon-reload
    
  7. Start, and enable (at boot) the service

    systemctl start x40.link && systemctl enable x40.link
    
  8. Add an entry in the "/etc/hosts" file pointing at localhost, with an appropriate prefix

    # DESTRUCTIVE ACTION. Take due care, or use vim.
    cat <<'EOF' | tee -a /etc/hosts
    
    127.0.0.1 x40
    EOF
    
  9. Navigate to http://x40 in your browser. It'll probably warn you about HTTPS, but you can click through that.