Sign inSign up

walkerzhuo/short-link

By walkerzhuo

•Updated over 1 year ago

A modern URL shortener with custom domains, manage your links and view the click rate statistics.

Image
Developer tools
Web servers
Content management system
0

115

walkerzhuo/short-link repository overview

short-link is a modern URL shortener with support for custom domains. Shorten URLs, manage your links and view the click rate statistics.

⁠How to run project locally? (Please upgrade your docker-compose to v2.x+)

  • Step1: copy default environment config file: .example.env
  • Step2: create docker-compose file, Please refer to the docker-compose.yml content below
  • Step3: docker compose -f docker-compose.yml -v up -d
#########                  .example.env                   #########
# App port to run on
PORT=3000

# The name of the site
SITE_NAME=Short Link

# The domain that this website is on
DEFAULT_DOMAIN=localhost:3000

# Generated link length
LINK_LENGTH=6

# Postgres database credential details
DB_HOST=localhost
DB_PORT=5432
DB_NAME=short_link
DB_USER=user
DB_PASSWORD=pass
DB_SSL=false

# Redis host and port
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=
# Optional: The number for Redis database, between 0 and 15. Defaults to 0.
# If you don't know what this is, then you probably don't need to change it.
REDIS_DB=0

# Disable registration
DISALLOW_REGISTRATION=false

# Disable anonymous link creation
DISALLOW_ANONYMOUS_LINKS=false

# The daily limit for each user
USER_LIMIT_PER_DAY=50

# Create a cooldown for non-logged in users in minutes
# Would be ignored if DISALLOW_ANONYMOUS_LINKS is set to true
# Set 0 to disable
NON_USER_COOLDOWN=0

# Max number of visits for each link to have detailed stats
DEFAULT_MAX_STATS_PER_LINK=5000

# Use HTTPS for links with custom domain
CUSTOM_DOMAIN_USE_HTTPS=false

# A passphrase to encrypt JWT. Use a long and secure key.
JWT_SECRET=securekey

# Admin emails so they can access admin actions on settings page
# Comma seperated
[email protected]

# Invisible reCaptcha secret key
# Create one in https://www.google.com/recaptcha/intro/
RECAPTCHA_SITE_KEY=
RECAPTCHA_SECRET_KEY=

# Google Cloud API to prevent from users from submitting malware URLs.
# Get it from https://developers.google.com/safe-browsing/v4/get-started
GOOGLE_SAFE_BROWSING_KEY=

# Your email host details to use to send verification emails.
# More info on http://nodemailer.com/
MAIL_HOST=
MAIL_PORT=80
MAIL_SECURE=true
MAIL_USER=
MAIL_FROM=
MAIL_PASSWORD=

# The email address that will receive submitted reports.
REPORT_EMAIL=

# Support email to show on the app
CONTACT_EMAIL=

# docker-compose.yml
services:
  short-link-web:
    build:
      context: .
      dockerfile: Dockerfile
    image: walkerzhuo/short-link:1.0
    container_name: standalone.short-link
    depends_on:
      - postgres
      - redis
    command: ./wait-for-it.sh postgres:5432 -- npm start
    ports:
      - "3000:3000"
    env_file:
      - .example.env # rename this file to .env on production
    environment:
      DB_HOST: postgres
      REDIS_HOST: redis

  redis:
    image: redis:6.0-alpine
    volumes:
      - short_link_redis_data:/data

  postgres:
    image: postgres:12-alpine
    environment:
      POSTGRES_USER: user
      POSTGRES_PASSWORD: pass
      POSTGRES_DB: short_link
    ports: 
      - "5432:5432"
    volumes:
      - short_link_postgres_data:/var/lib/postgresql/data

volumes:
  short_link_redis_data:
  short_link_postgres_data:
  • Please update the docker-compose first before pushing to production

⁠How to visit the system?

  • Default admin account: [email protected], password: changeMe123
  • Default website login page: http://localhost:3000/login # you can customize your domain
  • Default website home page: http://localhost:3000
  • Default postgresql config:
    • username: user
    • password: pass
    • host: postgres
    • database: short_link
    • port: 5432

Tag summary

Content type

Image

Digest

sha256:5d006f09e…

Size

425.1 MB

Last updated

over 1 year ago

docker pull walkerzhuo/short-link:1.0