51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Kutt 开源的网址缩短程序

Kutt 是一个开源的短网址程序,有了它可以在分享一些很长的链接的时候,进行缩短链接,使得分享 URL 更简洁。支持容器部署,虽是英文界面,但操作很简单,感兴趣的小伙伴可以试一下~

支持特性 {#支持特性}

  1. 开源免费;

  2. 自定义域支持;

  3. 缩短链接自定义 URL;

  4. 设置链接密码;

  5. 设置链接描述;

  6. 链接过期时间;

  7. 查看、编辑、删除、管理链接;

  8. 管理员帐户可查看、删除、禁止链接。

程序部署 {#程序部署}

如果常规安装的话需要安装 Node.js/PostgreSQL/Redis 等,所以用 Docker 来安装这个是最简单的。将下方的代码保存为.env

|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | # App port to run on PORT=3000 # The name of the site where Kutt is hosted SITE_NAME=Kutt # The domain that this website is on DEFAULT_DOMAIN=localhost:3000 # Generated link length LINK_LENGTH=6 # Postgres database credential details DB_HOST=postgres DB_PORT=5432 DB_NAME=postgres DB_USER= DB_PASSWORD= DB_SSL=false # Redis host and port REDIS_HOST=redis REDIS_PORT=6379 REDIS_PASSWORD= REDIS_DB= # 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 # 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 ADMIN_EMAILS= # 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 from example "Kutt <support@kutt.it>". Leave empty to use MAIL_USER MAIL_HOST= MAIL_PORT= 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

|---------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | version: "3" services: kutt: image: kutt/kutt depends_on: - postgres - redis command: ["./wait-for-it.sh", "postgres:5432", "--", "npm", "start"] ports: - "3000:3000" env_file: - .env environment: DB_HOST: postgres DB_NAME: kutt DB_USER: user DB_PASSWORD: pass REDIS_HOST: redis redis: image: redis:6.0-alpine volumes: - redis_data:/data postgres: image: postgres:12-alpine environment: POSTGRES_USER: user POSTGRES_PASSWORD: pass POSTGRES_DB: kutt volumes: - postgres_data:/var/lib/postgresql/data volumes: redis_data: postgres_data: |

启用服务 {#启用服务}

修改.envDEFAULT_DOMAIN=localhost:3000 值,将 localhost 改为域名,不然访问时会跳转出错。并确保邮箱相关的配置正确:

|---------------------|-------------------------------------------------------------------------------------| | 1 2 3 4 5 6 | MAIL_HOST= MAIL_PORT= MAIL_SECURE=true MAIL_USER= MAIL_FROM= MAIL_PASSWORD= |

然后通过下方命令启动服务:

|-----------|------------------------------| | 1 | docker-compose up -d |

注意事项 {#注意事项}

Kutt 默认是没有管理员用户的,需要通过邮箱注册,所以需要.env 里邮箱相关的内容都配置正确。

注册账号时始终提示失败 an error occurred,虽然不影响短链接的生成及使用,但无法登录管理员后台还是很难受的。

注册失败实际是没有发邮件激活成功,通过在作者的 Issues 里发现了有很多人大量反馈此问题,应该是对接 SMTP 服务的 bug。

这种方式可通过登录 PostgreSQL 容器,查找到对应用户验证 Token,再访问 URL 激活即可。

赞(0)
未经允许不得转载:工具盒子 » Kutt 开源的网址缩短程序