跳转到内容

跨境单商户版 · 部署指南文档

与银河版相同的 Docker + Nginx + SSL 流程。支付、报关、物流 webhook 回调必须走 HTTPS。推荐全程 Docker。文中域名、IP、密码均为示例,上线前必须替换。

组件 版本
JDK(镜像内) 17
MySQL 8.0
Redis 5.0+
Elasticsearch 7.x
XXL-JOB 3.0.0
Docker / Compose 当前稳定版

先在开发机把后端打好包,再放到生产机。服务器需已安装 dockerdocker compose

mall4j-shop
├─ mysql/initdb、mysql/data、mysql/my.cnf
├─ yami-shop-api # 用户端 jar
├─ yami-shop-multishop # 管理端 jar
├─ nginx/conf.d / html / ssl
└─ docker-compose.yml

SQL 用跨境 B2C 仓库编号脚本放入 initdb(首次 Compose 自动导入)。jar:mvn clean package -DskipTests 后放入

  • yami-shop-api-0.0.1-SNAPSHOT.jar
  • yami-shop-multishop-0.0.1-SNAPSHOT.jar

前端 dist → nginx/html/h5html/pchtml/multishop。证书 → nginx/ssl。Docker 优先读 Compose 环境变量(MYSQL_HOSTREDIS_HOSTELASTIC_ADDRESS 等)。非 Docker 改 application-prod.ymlmysql/data 禁止删除。

Terminal window
cd mall4j-shop
docker compose up -d --build

公网只开放 80/443。中间件端口不暴露。全局替换模板密码。

配置 用途
API 用户端 API,反代 :8112
管理后台 静态 + /apis → 管理端 jar
H5 / PC root html/h5html/pc,history try_files
IM / MinIO / XXL-JOB 按模板启用

80 跳 443,TLS 1.2/1.3。H5、支付、物流 webhook 一律 HTTPS。屏蔽 doc.html

server {
listen 80;
server_name cbec-b2c-multishop.example.com;
location / { return 301 https://$host$request_uri; }
}
server {
listen 443 ssl http2;
server_name cbec-b2c-multishop.example.com;
ssl_certificate ssl/your-cert.pem;
ssl_certificate_key ssl/your-cert.key;
ssl_protocols TLSv1.2 TLSv1.3;
location / {
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
proxy_pass http://mall4j-cbec-b2c-vs;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /apis {
rewrite ^/apis/(.*)$ /$1 break;
proxy_pass http://mall4j-cbec-b2c-multishop:8113;
proxy_cookie_path / "/; httponly; secure; SameSite=Lax";
}
location /apis/doc.html { return 404; }
}

用户端 API:

location / {
proxy_pass http://127.0.0.1:8112;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}

H5/PC 使用 try_files $uri $uri/ /;。Docker 中 html 对应 ./nginx/html:/usr/share/nginx/html

uni-app:Node ≥ 18.12,pnpm.env.production 后发行 H5。PC/管理后台 build 后放入对应 html 目录。小程序配置 HTTPS 合法域名。

Terminal window
java -jar -Xmx1024m -Dspring.profiles.active=prod yami-shop-api-0.0.1-SNAPSHOT.jar &
java -jar -Xmx512m -Dspring.profiles.active=prod yami-shop-multishop-0.0.1-SNAPSHOT.jar &

Nginx proxy_pass 改为内网 IP;XXL-JOB 单独部署。