一个基于Go语言开发的网站随机跳转系统,让用户可以随机访问已审核的网站,同时支持网站申请加入和管理员审核功能。
老陈传送门/ ├── main.go # 主程序入口 ├── go.mod # Go模块文件 ├── config/ │ └── config.go # 配置管理 ├── database/ │ └── db.go # 数据库连接 ├── models/ │ ├── website.go # 网站模型 │ └── admin.go # 管理员模型 ├── handlers/ │ ├── home.go # 首页处理 │ ├── teleport.go # 传送功能 │ ├── apply.go # 申请功能 │ └── admin.go # 管理员功能 ├── templates/ │ ├── index.html # 首页模板 │ ├── teleport.html # 传送页面 │ ├── apply.html # 申请页面 │ ├── init.html # 初始化页面 │ └── admin/ │ ├── login.html # 管理员登录 │ ├── dashboard.html # 管理后台 │ ├── websites.html # 网站管理 │ └── add_website.html # 添加网站 └── README.md
最简单的部署方式,类似 Alist 的一键部署体验:
# 克隆项目
git clone https://cnb.cool/FlashingChen/CSM.git
cd CSM
# Linux/macOS 一键启动
chmod +x docker-start.sh
./docker-start.sh start
# Windows 一键启动
docker-start.bat start
访问地址: http://localhost:8080
📖 详细的 Docker 部署说明请查看 DOCKER_DEPLOY.md
git clone https://cnb.cool/FlashingChen/CSM.git
cd CSM
如果是国内服务器,由于网络限制需要先配置Go代理:
# 配置Go代理
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOSUMDB=sum.golang.google.cn
go mod tidy
创建MySQL数据库:
CREATE DATABASE teleport_portal CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
创建 .env 文件或设置环境变量:
export DB_HOST=localhost
export DB_PORT=3306
export DB_USER=root
export DB_PASSWORD=your_password
export DB_NAME=teleport_portal
export SERVER_PORT=8080
go run main.go
打开浏览器访问 http://localhost:8080,首次访问会自动跳转到初始化页面。
确保服务器已安装:
将代码上传到网站目录:/www/wwwroot/go.chenyuxia.com
# 进入网站目录
cd /www/wwwroot/go.chenyuxia.com
# 克隆代码
git clone https://cnb.cool/FlashingChen/CSM.git .
# 配置Go代理(国内服务器必需)
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOSUMDB=sum.golang.google.cn
# 安装依赖
go mod tidy
在宝塔面板中创建数据库:
teleport_portalutf8mb4# 编译为可执行文件
go build -o teleport-portal main.go
# 设置执行权限
chmod +x teleport-portal
创建systemd服务文件:
sudo nano /etc/systemd/system/teleport-portal.service
添加以下内容:
[Unit]
Description=Teleport Portal Service
After=network.target mysql.service
[Service]
Type=simple
User=www
WorkingDirectory=/www/wwwroot/go.chenyuxia.com
ExecStart=/www/wwwroot/go.chenyuxia.com/teleport-portal
Restart=always
RestartSec=5
Environment=DB_HOST=localhost
Environment=DB_PORT=3306
Environment=DB_USER=your_db_user
Environment=DB_PASSWORD=your_db_password
Environment=DB_NAME=teleport_portal
Environment=SERVER_PORT=8080
[Install]
WantedBy=multi-user.target
# 重新加载systemd
sudo systemctl daemon-reload
# 启动服务
sudo systemctl start teleport-portal
# 设置开机自启
sudo systemctl enable teleport-portal
# 查看服务状态
sudo systemctl status teleport-portal
在宝塔面板中配置Nginx反向代理:
location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }
# 开放8080端口(如果需要)
sudo ufw allow 8080
# 或者在宝塔面板的安全设置中添加端口
/admin 进入管理后台A: 检查数据库配置信息,确保MySQL服务正常运行,数据库已创建。
A: 修改环境变量 SERVER_PORT 或在代码中修改端口号。
A: 确保程序有读写权限,特别是在Linux系统中。
A: 检查systemd服务配置,查看日志:sudo journalctl -u teleport-portal -f
欢迎提交Issue和Pull Request来改进项目!
MIT License
如有问题或建议,请通过以下方式联系:
老陈传送门 - 让互联网的探索更有趣! 🚀