Categorygithub.com/alexbrazier/go-url
module
1.1.0
Repository: https://github.com/alexbrazier/go-url.git
Documentation: pkg.go.dev

# README

Go URL

CircleCI Cypress Dashboard dependencies

A simple URL shortener written in Go with a React frontend and Postgres database.

Features

  • Shorten urls based on a user defined key
  • Alias a key to point to another short url
  • Open multiple pages at once by separating keys with a comma
  • Alias a key to point to multiple other keys
  • Use variables in URLs
  • Opensearch integration to provide suggestions directly to browser
  • Frontend to view most popular searches and search to find existing links
  • Frontend to allow anyone to add and edit links
  • Optional authentication using Azure AD or Okta
  • Slack / command integration
  • Slackbot integration

Demo

Getting Started

The recommended way to test and deploy is using Docker. You will need to run both the go-url app, and the Postgres DB.

Start Postgres

docker run -d -P --name db -e POSTGRES_PASSWORD=password -e POSTGRES_DB=go -e POSTGRES_ADDR=db:5432 postgres:11.3-alpine

Start App

docker run -p 1323:1323 -e HOSTS=localhost -e APP_URI=http://localhost:1323 --link db alexbrazier/go-url

Alteratively use the docker-compose file and run:

docker-compose up

Development

Open http://localhost:8080/go

Run Postgres manually or with Docker

docker-compose up postgres

Install node (via nvm), yarn & go

brew install nvm yarn go
nvm install

Start frontend

cd frontend
yarn
yarn start

Start API

cd api
dep ensure
POSTGRES_PASS=password HOSTS=localhost APP_URI=http://localhost:3000 go run server.go

Enviroment Configuration

Env VarRequiredDefaultExampleDescription
HOSTSyesgo.domain.com,go2.domain.comList of comma separated hosts that the server will be able to be accessed from
BLOCKED_HOSTSgo.domain.com,go2.domain.comList of hosts you want to block from being linked - HOSTS are already included to stop recursive calls
APP_URIyeshttps://go.domain.comDefault URI of app - used to link back to app
PORT1323Port the app will run on
DEBUGfalseEnable more logging
JSON_LOGSfalseUse JSON logs where possible
POSTGRES_ADDRlocalhost:5432Postgres db address
POSTGRES_DATABASEgoPostgres db name
POSTGRES_USERpostgresPostgres user
POSTGRES_PASSpasswordPostgres password
SLACK_TOKENxoxb-xxxxxxxxx-xxxxxxxx-xxxxSlack OAuth token to enable slackbot
SENTRY_API_DSNSentry DSN for go API
SENTRY_FRONTEND_DSNSentry DSN for react frontend
SLACK_SIGNING_SECRETxxxxxxxxxxxSlack signing secret to enable Slack /go command
SLACK_TEAM_IDTxxxxxxxxSlack team id to restrict slash command responses to single team
ENABLE_AUTHfalseEnable Azure auth or not - if enabled, all other fields must be filled in
AUTH_EXPIRY_SECONDS2592000Auth cookie expiry (default 30 days)
SECURE_COOKIEStrueUse secure https only cookies
AD_TENANT_IDAzure AD tenant ID
AD_CLIENT_IDAzure AD client ID
AD_CLIENT_SECRETAzure AD client secret
OKTA_CLIENT_IDOkta client ID
OKTA_CLIENT_SECRETOkta client secret
OKTA_ISSUERhttps://dev-123.oktapreview.com/oauth2/defaultOkta issuer url
SESSION_TOKENSecret session token to store the user sessions
ALLOWED_IPS110.1.10.2,1.1.22.0/24IP addresses or CIDRs that are always allowed access, even with auth enabled
ALLOW_FORWARDED_FORfalseRetrieve origin IP from X-Forwarded-For header. Only enable if source is trusted, e.g. via Cloudfront
FORWARDED_FOR_TRUST_LEVEL1Number of levels to trust X-Forwarded-For header - should map to number of proxies used

FAQ

Slackbot is posting multiple replies messages to a single message

When enabled, the Slackbot will be running on every node in a load balanced system. Either disable load balancing, or run a separate instance just for the Slackbot.

# Packages

No description provided by the author