667 字
3 分钟
Hoppscotch 部署教程
2026-05-12
无标签

Hoppscotch#

demo

桌面端/客户端

官方教程

部署教程#

数据库准备#

Terminal window
sudo -s -u postgres
psql
CREATE USER (用户名) WITH PASSWORD (密码)
CREATE DATABASE (数据库名称)
GRANT ALL PRIVILEGES ON DATABASE (数据库名称) to (用户名)

使用 AIO 容器#

创建并进入项目文件夹:

Terminal window
mkdir hoppscotch
cd hoppscotch

创建32个字符(无特殊符号)的密钥:

Terminal window
tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w 32 | head -1

创建 .env 文件,内容参考如下:

Terminal window
#-----------------------Backend Config------------------------------#
# Prisma Config
DATABASE_URL=postgresql://(用户名):(密码)@172.17.0.1:5432/(数据库名称) # or replace with your database URL
# (Optional) By default, the AIO container (when in subpath access mode) exposes the endpoint on port 80. Use this setting to specify a different port if needed.
HOPP_AIO_ALTERNATE_PORT=(服务端口)
# Sensitive Data Encryption Key while storing in Database (32 character)
DATA_ENCRYPTION_KEY=(32个字符(无特殊符号)的密钥)
# Whitelisted origins for the Hoppscotch App.
# This list controls which origins can interact with the app through cross-origin comms.
# - localhost ports (3170, 3000, 3100): app, backend, development servers and services
# - app://localhost_3200: Bundle server origin identifier
# NOTE: `3200` here refers to the bundle server (port 3200) that provides the bundles,
# NOT where the app runs. The app itself uses the `app://` protocol with dynamic
# bundle names like `app://{bundle-name}/`
WHITELISTED_ORIGINS=https://(你的域名),http://localhost:3170,http://localhost:3000,http://localhost:3100,app://localhost_3200,app://hoppscotch
#-----------------------Frontend Config------------------------------#
# Base URLs
VITE_BASE_URL=https://(你的域名)
VITE_SHORTCODE_BASE_URL=https://(你的域名)
VITE_ADMIN_URL=https://(你的域名)/admin
# Backend URLs
VITE_BACKEND_GQL_URL=https://(你的域名)/backend/graphql
VITE_BACKEND_WS_URL=wss://(你的域名)/backend/graphql
VITE_BACKEND_API_URL=https://(你的域名)/backend/v1
# Terms Of Service And Privacy Policy Links (Optional)
VITE_APP_TOS_LINK=https://docs.hoppscotch.io/support/terms
VITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/support/privacy
# Set to `true` for subpath based access
ENABLE_SUBPATH_BASED_ACCESS=true

拉取容器:

Terminal window
docker pull hoppscotch/hoppscotch

运行容器:

Terminal window
docker run -d -p (宿主机的服务端口):(容器的服务端口) --env-file .env --restart unless-stopped hoppscotch/hoppscotch

宿主机的服务端口和容器的服务端口需要保持一致

数据库迁移#

Terminal window
# 查询容器 id
docker ps -a
# 创建 AIO 容器
docker run -it --entrypoint sh --env-file .env hoppscotch/hoppscotch
# 数据库迁移
pnpm exec prisma migrate deploy

用户登录 SMTP#

容器运行后可通过 https://(你的域名)/admin 进入管理员控制面板

使用 网易邮箱 配置参考:

  • Mailer From Address: 你的163邮箱地址
  • Smtp Host: smtp.163.com
  • Smtp Port: 465
  • Smtp User: 你的163邮箱地址
  • Smtp Password: 不是登录密码,是授权密码
  • Smtp Secure: 勾选
  • Smtp Ignore Tls: 不勾选
  • Tls Reject Unauthorized: 勾选

用户登录 Github OAuth#

使用 Github OAuth:

  1. 点击右上角头像,在下拉框中点击 Settings
  2. 左侧侧边栏点击 Developer settings
  3. 选择 OAuth Apps
  4. 填写应用配置:
    • Homepage URL: 域名根目录,例如 https://{你的域名}/
    • Authorization callback URL: 授权回调,如果使用的 AIO,例如 https://{你的域名}/backend/v1/auth/github/callback
    • Client secrets: 创建客户端密钥

访问 https://你的域名/admin,进入 Settings >> Authentication >> OAuth

  • Client Id: 和 Github Auth App 里一样
  • Client Secret: 使用 Github Auth App 创建的客户端密钥
  • Callback Url: 和 Github Auth App 里一样
  • Scope: 必须填写 user:email,固定的文本内容
Hoppscotch 部署教程
https://fuwari.vercel.app/posts/运维/hoppscotch-部署教程/
作者
Asuwee
发布于
2026-05-12
许可协议
CC BY-NC-SA 4.0