IoT System Deployment
提示
The project has a separated frontend and backend, which need to be deployed separately.
Prerequisites
- A Java runtime is installed (to run the jar directly) or Tomcat (for war deployment).
- Node.js is installed, and frontend dependencies are installed before packaging.
- Dependency services are deployed: MySQL, Redis, and EMQX — see MySQL Installation, Redis Installation, and EMQX Installation.
- Nginx is installed to host the frontend static files and reverse-proxy the backend API and MQTT WebSocket — see Nginx Installation.
Recommended deployment order: dependency services → backend → frontend build → Nginx.
1. Backend Deployment
- Run package.bat in the
fastbee\springboot\bindirectory to package the project into a web application, generating the war/jar package file.
# Generated package directory
fastbee\springboot\fastbee-admin\target- jar deployment:
# Run from the command line
java –jar fastbee-admin.jar- war deployment:
# Change packaging to war in the fastbee\springboot\fastbee-admin\pom.xml file, then after packaging place it in the tomcat server's webapps directory
<packaging>war</packaging>2. Frontend Packaging
- Modify the
.env.productionfile in the root directory. The MQTT message server address uses port 8083 for the ws protocol; for the wss protocol, it is recommended to configure a proxy to access port 8083.
# EMQX API account (the backend address and EMQX API address are proxied through nginx)
VUE_APP_EMQX_API_USER_NAME = 'admin'
VUE_APP_EMQX_API_PASSWORD = 'public'
# EMQX message server connection address
VUE_APP_EMQX_SERVER_URL = 'ws://localhost:8083/mqtt'- Run the command to package the application
# Package for the production environment
npm run build:prodMake sure the dependency packages are installed before packaging. After a successful build, a dist folder is generated in the root directory, containing the built files — usually static files such as *.js, *.css, and index.html.
- Interface configuration
- Tianditu (China national map), Baidu Maps, Google Maps, and Seniverse Weather can be filled in under System Management - Parameter Configuration. Refer to the image below (keep the parameter keys consistent with the image).

3. Deploying the Frontend with Nginx
After the frontend is packaged, configure the upload path for the files in the dist directory: /var/data/vue. The backend deployment address is http://localhost:8080/ with default port 8080. The full configuration is as follows:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 10m;
gzip on;
gzip_min_length 1k;
gzip_buffers 16 64K;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
# Redirect Http to Https
# server {
# listen 80;
# server_name localhost;
# location / {
# rewrite ^(.*) https://$server_name$1 permanent;
# }
# }
server {
listen 80;
# The default SSL access port is 443
# listen 443 ssl;
server_name localhost;
charset utf-8;
# Path of the certificate file
# ssl_certificate /usr/share/nginx/ssl/fastbee.crt;
# Path of the private key file
# ssl_certificate_key /usr/share/nginx/ssl/fastbee.key;
# ssl_session_timeout 10m;
# Configure according to the following protocols
# ssl_protocols TLSv1.2 TLSv1.3;
# Configure cipher suites as follows, following the openssl standard
# ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
# ssl_prefer_server_ciphers on;
# Frontend
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
# Backend API
location /prod-api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/;
}
# Proxy wss connections to ws
location /mqtt {
proxy_pass http://localhost:8083/mqtt;
proxy_read_timeout 60s;
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'Upgrade';
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}4. Verification
- Backend: after startup, visit
http://localhost:8080/— you should get an application response rather than a connection refusal; check the startup log for port conflicts or data source connection errors. - Frontend: open the Nginx listen port in a browser; the home page and static assets should load without 404s.
- API proxy: perform an action such as login on the page; requests succeeding through
/prod-api/confirm the Nginx reverse proxy to the backend works. - MQTT: in the browser developer tools, confirm the WebSocket connection is established (direct
ws://<host>:8083/mqttor the Nginx-proxied/mqtt).
5. Troubleshooting
| Issue | Possible Cause | Solution |
|---|---|---|
| Frontend returns 404 after refresh | Nginx lacks the SPA fallback | Confirm location / contains try_files $uri $uri/ /index.html; |
| API requests return 502/504 | Backend not running or port mismatch | Confirm the backend process is running and proxy_pass points to the actual backend address |
| Page loads but APIs return 404 | /prod-api/ proxy not configured | Configure location /prod-api/ to point to the backend as shown |
| MQTT connection fails | Port 8083 not listening or /mqtt proxy missing | Check the EMQX WebSocket port and the Upgrade headers in the Nginx /mqtt proxy |
| Blank page or unreachable server after build | Wrong addresses in .env.production | Verify the backend and EMQX addresses, then rerun npm run build:prod |
提示
For more deployment materials, refer to the RuoYi system documentation (Chinese)


