
Platinum Sponsor
CEOACC.COM | Wholesale Social Media Accounts from the Source
Buy Facebook accounts, Wholesale Instagram accounts, Buy Twitter accounts, Buy TikTok accounts, Buy Telegram accounts, Buy Apple IDs, Buy Google Gmail accounts


config.yml Detailed Explanation and Recommended Configuration Last updated: 2026-08-11
Applies to: the current
dujiao-nextmain branch. Field names and built-in defaults followinternal/config/config.go.
When the backend starts, values are resolved in the following order:
config.ymlserver.port ⇢ SERVER_PORTThe application looks for config.yml in the current directory, its parent directory, and ./etc. If the file is missing or cannot be read, startup logs a warning and continues with environment variables and built-in defaults. However, the later security check still stops startup unless all three valid runtime secrets are supplied through the environment. A production deployment should keep a permission-protected copy of the file in its backup set.
Except for the special bootstrap variables DJ_DEFAULT_ADMIN_USERNAME and DJ_DEFAULT_ADMIN_PASSWORD, an environment variable is normally formed from the full configuration key by uppercasing it and replacing . with _. For example, app.secret_key becomes APP_SECRET_KEY.
sqlite for simple, dependency-free setup.postgres for better concurrency, reliability, and observability.Using SQLite in production means accepting:
Before starting the service, run the following command three times and paste the three different outputs into app.secret_key, jwt.secret, and user_jwt.secret:
openssl rand -hex 32The three runtime secrets must be different. A built-in value, a known placeholder, a value shorter than 32 characters, or a duplicated value makes startup fail. Do not keep the angle-bracket placeholders below.
Use this for single-machine development and low-concurrency testing.
app:
secret_key: "<first openssl output>"
server:
host: 0.0.0.0
port: 8080
mode: debug
log:
dir: ""
filename: app.log
max_size_mb: 100
max_backups: 7
max_age_days: 30
compress: true
database:
driver: sqlite
dsn: ./db/dujiao.db?_busy_timeout=5000&_journal_mode=WAL&_synchronous=NORMAL
pool:
max_open_conns: 1
max_idle_conns: 1
conn_max_lifetime_seconds: 0
conn_max_idle_time_seconds: 0
jwt:
secret: "<second openssl output>"
expire_hours: 24
user_jwt:
secret: "<third openssl output>"
expire_hours: 24
remember_me_expire_hours: 168SQLite reminders:
max_open_conns at 1; multiple writers make database is locked errors more likely._journal_mode=WAL can improve read/write concurrency on a single machine.Use this for production workloads with predictable concurrent traffic.
app:
secret_key: "<first openssl output>"
server:
host: 0.0.0.0
port: 8080
mode: release
# These values apply only when the reverse proxy runs on the same host
trusted_proxies:
- 127.0.0.1/32
- ::1/128
log:
dir: /var/log/dujiao-next
filename: app.log
max_size_mb: 100
max_backups: 14
max_age_days: 30
compress: true
database:
driver: postgres
dsn: host=127.0.0.1 port=5432 user=dujiao password=CHANGE_ME dbname=dujiao sslmode=disable TimeZone=Asia/Shanghai
pool:
max_open_conns: 50
max_idle_conns: 10
conn_max_lifetime_seconds: 1800
conn_max_idle_time_seconds: 600
jwt:
secret: "<second openssl output>"
expire_hours: 24
user_jwt:
secret: "<third openssl output>"
expire_hours: 24
remember_me_expire_hours: 168PostgreSQL reminders:
max_open_conns than the PostgreSQL max_connections budget.conn_max_lifetime_seconds so network infrastructure does not unexpectedly reclaim indefinitely long-lived connections.TimeZone explicitly to keep order and log timestamps aligned.Use this connection-pool profile for a small production workload on a low-spec server:
database:
driver: postgres
dsn: host=127.0.0.1 port=5432 user=dujiao password=CHANGE_ME dbname=dujiao sslmode=disable TimeZone=Asia/Shanghai
pool:
max_open_conns: 20
max_idle_conns: 5
conn_max_lifetime_seconds: 1200
conn_max_idle_time_seconds: 300These are general starting points for API traffic, admin operations, and payment callbacks:
max_open_conns120-100, adjusted to workload and database capacitymax_idle_connsmax_open_connsconn_max_lifetime_seconds900-3600; 0 means unlimitedconn_max_idle_time_seconds300-1200; 0 means unlimitedCommon mistakes:
max_idle_conns > max_open_connsmax_open_conns so high that the database returns too many clientsapp | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
secret_key | string | change-me-32-byte-secret-key!! | Root AES-256 encryption key for payment credentials, Bot Tokens, and other sensitive data | Generate separately with openssl rand -hex 32 |
totp_issuer | string | Dujiao-Next | Issuer name shown in administrator and user 2FA authenticator apps | Use a stable site name and avoid special characters such as & |
Do not rotate app.secret_key casually after deployment. Existing encrypted database values cannot be decrypted with a different key. It must differ from both JWT secrets and must be backed up with the database.
server | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
host | string | 0.0.0.0 | Listen address | 0.0.0.0 |
port | string | 8080 | Service port | 8080 |
mode | string | debug | Runtime mode: debug or release | Use release in production |
trusted_proxies | []string | 127.0.0.1/32, ::1/128 | Proxy IP addresses/CIDRs from which Gin may trust forwarded client-IP headers | List only real reverse proxies; use [] when there is no proxy |
An empty trusted_proxies list disables trust in forwarded headers and uses the TCP peer address. Docker, load balancer, and CDN deployments must use their real proxy networks. The application rejects 0.0.0.0/0 and ::/0 because they trust every source. This setting controls client-IP resolution only; it is separate from reseller.trusted_forwarded_host.
log | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
dir | string | "" | Log directory; an empty value uses logs under the working directory | Set explicitly in production |
filename | string | app.log | Log filename | app.log |
max_size_mb | int | 100 | Maximum size of one file in MB | 100 |
max_backups | int | 7 | Number of rotated files to retain | 7-14 |
max_age_days | int | 30 | Retention period in days | 30 |
compress | bool | true | Compress rotated files | true |
database | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
driver | string | sqlite | sqlite or postgres | Prefer postgres in production |
dsn | string | ./db/dujiao.db | Database connection string | Configure for the environment |
pool.max_open_conns | int | 1 | Maximum open connections | SQLite=1; PostgreSQL=20-100 |
pool.max_idle_conns | int | 1 | Maximum idle connections | 5-20, or 20%-40% of open connections |
pool.conn_max_lifetime_seconds | int | 0 | Maximum connection lifetime; 0 is unlimited | 900-3600 |
pool.conn_max_idle_time_seconds | int | 0 | Maximum idle time; 0 is unlimited | 300-1200 |
jwt / user_jwt | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
jwt.secret | string | change-me-in-production | Administrator token signing secret | Generate separately with openssl rand -hex 32 |
jwt.expire_hours | int | 24 | Administrator token expiration in hours | 24 |
user_jwt.secret | string | user-change-me-in-production | User token signing secret | Generate separately with openssl rand -hex 32 |
user_jwt.expire_hours | int | 24 | Normal user token expiration in hours | 24 |
user_jwt.remember_me_expire_hours | int | 168 | Remember-me user token expiration | 168 (7 days) |
Startup fails if any of app.secret_key, jwt.secret, or user_jwt.secret is weak, is still a known placeholder, or duplicates another secret.
redis | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
enabled | bool | true | Enable Redis | Recommended in production |
host | string | 127.0.0.1 | Redis host | Configure for the environment |
port | int | 6379 | Redis port | 6379 |
password | string | "" | Redis password | Set in production |
db | int | 0 | Redis database index | 0 |
prefix | string | dj | Key prefix | dj or a deployment-specific value |
queue | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
enabled | bool | true | Enable the asynchronous queue | Recommended |
host | string | 127.0.0.1 | Queue Redis host | May share the Redis server while using a different DB |
port | int | 6379 | Queue Redis port | 6379 |
password | string | "" | Queue Redis password | Set in production |
db | int | 1 | Queue Redis database index | 1 |
concurrency | int | 10 | Worker concurrency | 5-20 |
queues | map | default:10, critical:5 | Queue names and weights | Adjust as needed |
upstream_sync_interval | duration string | 5m (service fallback) | Scheduled upstream product inventory synchronization interval | Use a Go duration such as 5m or 1h |
If queue.enabled=true but Redis is unavailable, asynchronous work such as email delivery fails or accumulates.
all (API + Worker).queue.enabled=false, start with -mode api; otherwise the Worker cannot initialize.upstream_sync_interval. The admin setting accepts 5 to 1,440 minutes.upload | Field | Type | Built-in default | Description | Recommendation |
|---|---|---|---|---|
max_size | int64 | 10485760 | Upload size limit in bytes | 10 MB or a tighter business limit |
allowed_types | []string | JPEG, PNG, GIF, WebP | Allowed MIME types | Keep only required types |
allowed_extensions | []string | .jpg, .jpeg, .png, .gif, .webp | Allowed extensions | Keep aligned with MIME types |
max_width / max_height | int | 4096 | Raster image dimension limit | 4096 |
SVG can carry scripts, so the official config.yml.example now ships with it commented out. To enable it, add image/svg+xml to allowed_types and .svg to allowed_extensions; uploads then get extra safety checks (see Security Best Practices).
web This section controls the embedded frontends. In fullstack builds, the user frontend is mounted at / and this setting chooses the admin entry path.
| Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
admin_path | string | /admin | Admin frontend path prefix | Use a hard-to-guess path |
web:
admin_path: "/dj-mgmt-7x9k2"Rules and behavior:
/, must not end with /, and cannot be /.-, ., _, ~, and @, but cannot be . or ... Gin route metacharacters such as : and * are rejected./api, /uploads, or /health.<base href> at startup./.-tags fullstack.cors | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
allowed_origins | []string | ["*"] | Allowed origins | List exact production origins |
allowed_methods | []string | GET, POST, PUT, DELETE, OPTIONS, PATCH | Allowed methods | Keep the minimum set |
allowed_headers | []string | See config.yml.example | Allowed request headers | Keep only what the application needs |
allow_credentials | bool | true | Whether credentials are allowed | Match the frontend policy |
max_age | int | 600 | Preflight cache duration in seconds | 600 |
In the current implementation, when allow_credentials=true and the list contains *, the server reflects any request Origin. This effectively permits every origin to send credentialed requests, so production must use exact scheme, host, and port values.
security | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
login_rate_limit.window_seconds | int | 300 | Rate-limit window in seconds | 300 |
login_rate_limit.max_attempts | int | 5 | Maximum failed attempts in the window | 5 |
login_rate_limit.block_seconds | int | 900 | Block duration after the limit is reached | 900 |
password_policy.min_length | int | 8 | Minimum password length | 8 or more |
password_policy.require_upper | bool | true | Require an uppercase letter | true |
password_policy.require_lower | bool | true | Require a lowercase letter | true |
password_policy.require_number | bool | true | Require a number | true |
password_policy.require_special | bool | false | Require a special character | Enable as needed |
email | Field | Type | Built-in default | Description | Recommendation |
|---|---|---|---|---|
enabled | bool | false | Enable email | Enable only after a real delivery test |
host | string | "" | SMTP host | Follow the provider settings |
port | int | 587 | SMTP port | 587 is common for STARTTLS; 465 for implicit TLS |
username / password | string | "" | SMTP account and password/app password | Use a dedicated app password |
from / from_name | string | "" | Sender address and display name | Use a verified business-domain mailbox |
use_tls | bool | true | Use STARTTLS | Mutually exclusive with use_ssl |
use_ssl | bool | false | Use TLS immediately on connect | Mutually exclusive with use_tls |
verify_code.expire_minutes | int | 10 | Verification-code lifetime in minutes | 10 |
verify_code.send_interval_seconds | int | 60 | Minimum resend interval per target in seconds | 60 |
verify_code.max_attempts | int | 5 | Maximum verification attempts | 5 |
verify_code.length | int | 6 | Numeric code length (4-10) | 6 |
The official example uses port 465/SSL and placeholder SMTP details. Those are not built-in defaults; choose TLS or SSL according to your provider.
bootstrap | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
default_admin_username | string | "" | Initial administrator username | Set your own administrator username explicitly |
default_admin_password | string | "" | Initial administrator password | Use a strong password that satisfies security.password_policy |
admins table is empty.DJ_DEFAULT_ADMIN_USERNAME / DJ_DEFAULT_ADMIN_PASSWORD (environment) > bootstrap.default_admin_username / bootstrap.default_admin_password (config.yml) > system defaults.release mode, if neither the environment nor config.yml provides an administrator password, default administrator initialization is skipped.release mode, a known default password or one that violates the current password policy makes startup fail. Other modes log a warning.order | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
payment_expire_minutes | int | 15 | Pending-payment order timeout in minutes | 15-30 |
max_refund_days | int | 30 | Longest period in which an administrator may record a manual refund or refund to the internal wallet, counted from payment time (or creation time when absent) | Follow the after-sales policy; 0 means unlimited, maximum 3650 |
telegram_auth (Optional) | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
enabled | bool | false | Enable Telegram login | Enable after configuration is complete |
bot_username | string | "" | Bot username without @ | For example, dujiao_login_bot |
bot_token | string | "" | Bot Token; OIDC also derives its numeric client_id from the token prefix | Generate with BotFather and keep secret |
client_secret | string | "" | Telegram OIDC Client Secret | Generate under Web Login in BotFather and keep secret |
oidc_redirect_uri | string | "" | Telegram OIDC browser callback page | https://store.example.com/auth/telegram/callback |
mini_app_url | string | "" | Telegram Mini App page URL | Keep aligned with the BotFather Web App URL |
login_expire_seconds | int | 300 | Login-data validity (30-86400 seconds) | 300 |
replay_ttl_seconds | int | 300 | Replay-protection lifetime (60-86400 seconds) | 300 |
With only bot_token, the site uses the legacy Login Widget. Supplying a valid client_secret and oidc_redirect_uri switches web login to OIDC. The callback must be a valid HTTP(S) URL and must also be added to BotFather Allowed URLs. mini_app_url only exposes the Mini App entry; it does not enable web login.
google_auth (Optional) Google sign-in uses Google Identity Services and requests no Gmail read or send permissions.
| Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
enabled | bool | false | Enable Google account sign-in | Enable after configuration is complete |
client_id | string | "" | Google OAuth 2.0 Web Client ID, not a Client Secret | Use a dedicated production client |
google_auth:
enabled: true
client_id: "1234567890-xxxx.apps.googleusercontent.com"Register every real access origin under Authorized JavaScript origins in the matching Google Cloud Web client:
https://shop.example.comhttps://brand.example.nethttp://localhost:5173An origin includes the scheme and port, if any, but no path. Each main-site and white-label origin must be registered separately.
Desktop browsers and Android use popup/FedCM. iOS and iPadOS use Google Identity Services redirect form_post, so also register an exact Authorized redirect URI for every real domain:
https://shop.example.com/api/v1/auth/google/redirect/callbackhttps://brand.example.net/api/v1/auth/google/redirect/callbackThe redirect URI must exactly match the scheme, domain, port, and path seen by the browser and must stay same-origin with the frontend. The iOS/iPadOS redirect flow requires enabled, reachable Redis 7 because one-time state/handoff values are atomically consumed with GETDEL. Redis failure makes redirect login and binding unavailable, while desktop/Android popup login does not use that state store.
The Google Client ID is public browser configuration, not a secret. Do not add a Client Secret; this feature does not request Gmail API scopes.
captcha (Optional) The official config.yml.example currently does not expand this section, but the code and admin settings fully support it. The default is provider=none with every scene disabled.
| Field | Default | Description |
|---|---|---|
provider | none | none, image, or turnstile |
scenes.login | false | Login |
scenes.register_send_code | false | Send a registration email code |
scenes.reset_send_code | false | Send a password-reset email code |
scenes.guest_create_order | false | Guest order creation |
scenes.gift_card_redeem | false | Gift-card redemption |
image.length | 5 | Image-captcha character count (4-8) |
image.width / image.height | 240 / 80 | Image dimensions; width at least 100 and height at least 40 |
image.noise_count / image.show_line | 2 / 2 | Noise-dot and interference-line counts |
image.expire_seconds | 300 | Lifetime (30-3600 seconds) |
image.max_store | 10240 | Maximum in-memory captcha entries, at least 100 |
turnstile.site_key / secret_key | "" | Cloudflare Turnstile keys; both are required when Turnstile is active |
turnstile.verify_url | Cloudflare verification endpoint | Server-side verification URL |
turnstile.timeout_ms | 2000 | Server-side verification timeout (500-10000 ms) |
Turnstile example:
captcha:
provider: turnstile
scenes:
login: true
register_send_code: true
reset_send_code: true
guest_create_order: true
gift_card_redeem: true
turnstile:
site_key: "<your-site-key>"
secret_key: "<your-secret-key>"
verify_url: "https://challenges.cloudflare.com/turnstile/v0/siteverify"
timeout_ms: 2000If any scenes.* switch is enabled, provider cannot remain none. A captcha configuration saved in the admin panel overrides this entire section.
reseller (Optional) | Field | Type | Default | Description | Recommendation |
|---|---|---|---|---|
enabled | bool | false | Enable reseller/white-label tenant resolution | Enable only after domain, DNS, TLS, and tenant acceptance testing |
main_hosts | []string | localhost, 127.0.0.1, ::1 | Hosts that are always treated as the main site | List every production main-site hostname without scheme or path |
trusted_forwarded_host | bool | false | Prefer X-Forwarded-Host when resolving the tenant | Enable only when a trusted proxy overwrites the header and the backend cannot be reached directly |
subdomain_base | string | "" | Base domain used to assign system subdomains | For example, shop.example.com, with wildcard DNS/TLS configured first |
self_apply_enabled | bool | true | Let regular users apply for reseller status | Follow the operating policy |
settlement_confirm_days | int | 7 | Confirmation period before reseller profit becomes withdrawable | 0 is immediate; range 0-3650 |
When enabled, a request host in main_hosts is treated as the main site. Other hosts resolve only to active, verified reseller domains stored in the database; unknown hosts do not silently fall back to the main site. trusted_forwarded_host and server.trusted_proxies are separate trust switches: the former trusts a tenant-host header, while the latter trusts client-IP headers. See the Reseller Guide for business configuration.
The following groups can be changed in admin settings and take priority over config.yml:
payment_expire_minutes and max_refund_days)queue.upstream_sync_intervalconfig.yml is the fallback only while the database has no corresponding setting. Once an admin setting has been saved, the database value remains authoritative across restarts. If editing config.yml has no effect, inspect the admin setting or clear the corresponding persisted value.
APP_SECRET_KEY=...SERVER_MODE=releaseDATABASE_DSN=host=127.0.0.1 ...JWT_SECRET=...USER_JWT_SECRET=...WEB_ADMIN_PATH=/dj-mgmt-7x9k2DJ_DEFAULT_ADMIN_USERNAME=adminDJ_DEFAULT_ADMIN_PASSWORD=<your-strong-password>REDIS_HOST=127.0.0.1CAPTCHA_TURNSTILE_SITE_KEY=...TELEGRAM_AUTH_ENABLED=trueTELEGRAM_AUTH_OIDC_REDIRECT_URI=https://shop.example.com/auth/telegram/callback (keep the matching empty YAML key; the official example includes it)RESELLER_ENABLED=trueRule: . in the configuration key is converted to _. An environment override is reliable only for keys known through built-in defaults or the loaded YAML. An environment-driven deployment should therefore retain a minimal YAML file containing the empty official-example keys such as telegram_auth.client_secret, telegram_auth.oidc_redirect_uri, and telegram_auth.mini_app_url. Lists and maps are also less predictable to express as environment variables, so keep values such as trusted_proxies, allowed_origins, and queues in YAML.
database is lockedmax_open_conns at 1 and include _busy_timeout in the DSN.pq: sorry, too many clients alreadymax_open_conns or raise PostgreSQL max_connections with an appropriate capacity plan.TimeZone and the host timezone.queue.enabled, queue Redis connectivity, and whether a Worker is running.-mode api, or whether queue/Redis is unavailable and timeout tasks are not consumed.app.secret_key, jwt.secret, and user_jwt.secret separately; make each at least 32 characters and ensure all three differ.server.trusted_proxies; list only real proxy IPs/CIDRs and never trust all networks.config.yml.server.mode=releaseapp.secret_key, jwt.secret, and user_jwt.secret are three different high-entropy values, and app.secret_key is safely backed upserver.trusted_proxies contains only real proxy addresses/networks, or is an empty list when no proxy is usedall mode, queue.enabled=true and queue Redis is reachable-mode api and the reduced asynchronous capability is understoodweb.admin_path no longer uses the default /adminclient_secret, and the callback have passed a real login testmain_hosts, subdomain_base, DNS/TLS, and the proxy Host trust boundary have passed acceptance testing