---
title: "Deploy SiYuan Notes"
description: "Private SiYuan knowledge base with a durable workspace and login gateway"
category: "Other"
url: https://railway.com/deploy/siyuan-notes
---

# Deploy SiYuan Notes

Private SiYuan knowledge base with a durable workspace and login gateway

**[Deploy SiYuan Notes on Railway](https://railway.com/template/siyuan-notes)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/siyuan-notes/manifest.json

- **Creator:** Anton Orel's Projects
- **Category:** Other
- **Total deploys:** 1

## Template content

### SiYuan

- **Image:** b3log/siyuan:v3.8.11@sha256:4166c882818eea4aafb5e7c42f2e8568184b611d20953eff10e2cb6f08fe9c65
- **Start command:** `/bin/sh -ec 'case "${SIYUAN_ACCESS_AUTH_CODE:-}" in "" | *[!A-Za-z0-9._-]*) echo "SIYUAN_ACCESS_AUTH_CODE must be set to letters, digits, dot, dash or underscore only; refusing to start" >&2; exit 64;; esac; [ "${#SIYUAN_ACCESS_AUTH_CODE}" -ge 16 ] || { echo "SIYUAN_ACCESS_AUTH_CODE must have 16 or more characters; refusing to start" >&2; exit 64; }; [ -z "${SIYUAN_ACCESS_AUTH_CODE_BYPASS:-}" ] || { echo "SIYUAN_ACCESS_AUTH_CODE_BYPASS would turn the lock screen off; remove it. Refusing to start" >&2; exit 64; }; [ "${PORT:-}" = 6806 ] || { echo "PORT must be 6806, the port the gateway and health check use; refusing to start" >&2; exit 64; }; mkdir -p /siyuan/workspace; exec /opt/siyuan/entrypoint.sh serve --workspace=/siyuan/workspace/ --port=6806 --fixed-port=false'`
- **Health check:** /api/system/version

### SiYuan Gateway

- **Image:** caddy:2.11.9-alpine@sha256:003a97808e781aa9f7e75cc2f43d34d461099031faf5e20faefb9f61126836f0
- **Start command:** `/bin/sh -ec '[ "${#SIYUAN_GATEWAY_PASSWORD}" -ge 16 ] || { echo "SIYUAN_GATEWAY_PASSWORD must have 16 or more characters; refusing to start" >&2; exit 64; }; case "${SIYUAN_GATEWAY_PASSWORD}" in *[[:cntrl:]]*) echo "SIYUAN_GATEWAY_PASSWORD must be a single line without control characters; refusing to start" >&2; exit 64;; esac; case "${SIYUAN_GATEWAY_USERNAME:-}" in "" | *[!A-Za-z0-9._-]*) echo "SIYUAN_GATEWAY_USERNAME must be letters, digits, dot, dash or underscore; refusing to start" >&2; exit 64;; esac; case "${SIYUAN_UPSTREAM:-}" in "" | *[!A-Za-z0-9.:-]*) echo "SIYUAN_UPSTREAM must be host:port; refusing to start" >&2; exit 64;; esac; case "${PORT:-}" in "" | *[!0-9]*) echo "PORT must be a number; refusing to start" >&2; exit 64;; esac; SIYUAN_GATEWAY_PASSWORD_HASH="$(printf "%s\n" "$SIYUAN_GATEWAY_PASSWORD" | caddy hash-password)"; export SIYUAN_GATEWAY_PASSWORD_HASH; unset SIYUAN_GATEWAY_PASSWORD; rm -f /tmp/Caddyfile; printf %s "ewoJYWRtaW4gb2ZmCglhdXRvX2h0dHBzIG9mZgoJcGVyc2lzdF9jb25maWcgb2ZmCglzZXJ2ZXJzIHsKCQkjIFJhaWx3YXkncyBlZGdlIGNvbm5lY3RzIGZyb20gMTAwLjY0LjAuMC8xMCBhbmQgcmVwbGFjZXMgdGhlIGNsaWVudCdzIGZvcndhcmRpbmcgaGVhZGVyczoKCQkjIFgtUmVhbC1JUCBpcyB0aGUgY2xpZW50LCBYLUZvcndhcmRlZC1Gb3IgaXMgIjxjbGllbnQ+LCA8ZWRnZSBwdWJsaWMgYWRkcmVzcz4iLiBUYWtlIHRoZQoJCSMgY2xpZW50IGZyb20gWC1SZWFsLUlQIG9ubHkgZnJvbSB0aGF0IHJhbmdlOyBhbnkgb3RoZXIgcGVlciBpcyBpdHMgb3duIGNsaWVudCBhZGRyZXNzLgoJCXRydXN0ZWRfcHJveGllcyBzdGF0aWMgMTAwLjY0LjAuMC8xMAoJCWNsaWVudF9pcF9oZWFkZXJzIFgtUmVhbC1JUAoJfQp9CgojIFNpWXVhbiB0cnVzdHMgZm9yd2FyZGluZyBoZWFkZXJzIG9ubHkgZnJvbSBhIGxvb3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WVVBTl9HQVRFV0FZX1VTRVJOQU1FfSB7JFNJWVVBTl9HQVRFV0FZX1BBU1NXT1JEX0hBU0h9CgkJfQoJCXJldmVyc2VfcHJveHkgeyRTSVlVQU5fVVBTVFJFQU19IHsKCQkJaGVhZGVyX3VwIC1BdXRob3JpemF0aW9uCgkJCWltcG9ydCBjbGllbnRfYWRkcmVzcwoJCQlmbHVzaF9pbnRlcnZhbCAtMQoJCX0KCX0KfQo=" | base64 -d >/tmp/Caddyfile; export XDG_CONFIG_HOME=/tmp/caddy/config XDG_DATA_HOME=/tmp/caddy/data; exec setpriv --nnp su -p -s /usr/bin/caddy -- nobody run --config /tmp/Caddyfile --adapter caddyfile'`
- **Health check:** /healthz
- **Public domain:** Yes

## Documentation

# Deploy and Host SiYuan Notes on Railway

Deploy SiYuan, the privacy-first, block-based note-taking app and personal knowledge base, with its workspace on a persistent volume and a password-protected gateway in front of it. Write in a Markdown WYSIWYG editor, link and embed blocks, build databases, query your notes with SQL and review flashcards, all from your browser.

## About Hosting SiYuan Notes

[SiYuan](https://github.com/siyuan-note/siyuan) is an open-source (AGPL-3.0) alternative to Notion and Obsidian with block references, two-way links, tags, full-text search, databases, PDF annotation and an AI assistant that works with your own OpenAI-compatible key. This template runs the official SiYuan `v3.8.11` image, pinned to an exact digest, as a private service with its workspace on a 5 GB Railway volume, and puts a Caddy gateway with a generated password in front of it. SiYuan's own lock-screen password is generated too and is required on every new session.

## Why Deploy SiYuan Notes on Railway

A SiYuan server on the open internet is only as safe as its lock screen, and several of SiYuan's routes answer before the lock screen is checked. This template makes an authenticated gateway the only public entry point, keeps SiYuan on Railway's private network, and refuses to start SiYuan without a strong access auth code or with the lock screen disabled. Your notes survive restarts and redeploys on the attached volume, the images are pinned, and both credentials are generated for you.

## Common Use Cases

- A personal knowledge base and journal you can open from any browser, with daily notes, block references and backlinks.
- Research notes and reading highlights with PDF annotation, tags and SQL-powered queries.
- Study with spaced-repetition flashcards built from your own notes.

## Dependencies for SiYuan Notes Hosting

Nothing outside Railway. Both credentials are generated at deploy time.

### Deployment Dependencies

- SiYuan `v3.8.11` (official `b3log/siyuan` image): https://github.com/siyuan-note/siyuan
- Caddy `2.11.9` for HTTP Basic Auth and the public reverse proxy: https://caddyserver.com
- A Railway volume for the SiYuan workspace.

After deployment, open the `SiYuan Gateway` domain and sign in with `SIYUAN_GATEWAY_USERNAME` and `SIYUAN_GATEWAY_PASSWORD` from that service's variables, then enter `SIYUAN_ACCESS_AUTH_CODE` from the `SiYuan` service's variables on SiYuan's lock screen.

SiYuan publishes security advisories often, and some are fixed only in prereleases: this template pins the latest stable release (3.8.11) and moves to the next stable one when it ships. The gateway blocks unauthenticated attacks but not content you import or AI output you view after signing in, so until then avoid importing untrusted packages, treat AI output as untrusted, and leave the Publish service off. See the advisories at https://github.com/siyuan-note/siyuan/security/advisories

This is a single-user deployment for use in a browser. SiYuan's desktop and mobile apps cannot connect to a SiYuan server, and the Docker build has no PDF, HTML or Word export. External API clients that send their own `Authorization` header (API tokens, clipper extensions, WebDAV) cannot pass the gateway; plugins inside the SiYuan UI work normally.


## Similar templates

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — Self-hosted virtual tabletop for role-playing games (license required)
- [Double Commander in your browser](https://railway.com/deploy/double-commander-in-your-browser) — The Double Commander file manager in the cloud, from any device

Open this page in a browser: https://railway.com/deploy/siyuan-notes
