https://github.com/GAS85/ownPastebin/
6.6K
A minimal, RAM-friendly paste service with support for raw uploads, TTL, burn-after-read, optional encryption, and pluggable storage backends.
https://sitnikov.eu/pastebin/โ
โก Fast and lightweight
๐ Pluggable storage:
๐ฅ Burn-after-read pastes
โณ TTL (expiration support)
๐ Optional server-side encryption with AES-GCM
๐ Optional end-to-end encryption with AES-GCM
๐ฆ Binary-safe uploads/downloads
๐ง Designed to be memory efficient
๐ i18n support - different languages as json files
๐จ Theme support - set predefined Theme or use custom CSS to override
๐ช Cookie and Privacy Notice support - set your own links to cookie and privacy policy
๐ Custom links support - set your own personal link with icon to any service
All configuration is done via environment variables.
The application automatically selects the first available backend, but it is recommended to configure only 1 of them, or use defaults:
PASTEBIN_REDIS_URLPASTEBIN_POSTGRES_URLPASTEBIN_SQLITE_PATHPASTEBIN_REDIS_URL - Valkey/Redis connection string. No default - if not set, Valkey/Redis is disabled. Example:
redis://valkey:6379/0
redis://redis:6379/0
PASTEBIN_POSTGRES_URL - PostgreSQL connection string. Used if Valkey/Redis is not configured. No default - if not set, PostgreSQL is disabled. Example:
postgresql://user:pass@postgres:5432/pastebin
PASTEBIN_SQLITE_PATH - Path to SQLite database file. Default:
/app/data/pastes.db
PASTEBIN_SQLITE_PAGE_SIZE - You can set SQLite Page size for a new table. Valid values are power of 2 from 512 to 65536. You can calculate it roughly on following basis:
4096 is default - good for typical text pastes (< 100 KB).8192 or 16384 - better when pastes are regularly several MB, because each paste fits in fewer pages, reducing I/O and B-tree depth.PASTEBIN_BASE_URL- Public base URL of your service. Default:
http://localhost:8080
Following prefixes are supported:
PASTEBIN_BASE_URL=http://localhost:8080 or PASTEBIN_BASE_URL=https://pastebin.myserver.com/pastebin - PASTEBIN_BASE_URL=https://myserver.com/pastebin/tools/paste - PASTEBIN_BASE_URL=https://myserver.com/tools/pastePASTEBIN_HOST - Bind address. Default: 0.0.0.0
PASTEBIN_PORT - Port to listen to. Default: 8080
PASTEBIN_TLS_KEY - Provide path to TLS Key to enable TLS Support directly on a service.
PASTEBIN_TLS_CERT - Provide path to TLS Certificate to enable TLS Support directly on a service.
PASTEBIN_TRUSTED_PROXY - Provide IP or CIDR of trusted proxies, so that X-Forwarded-For header will be used.
PASTEBIN_LOG_LEVEL - Set log level. Default: Info.
PASTEBIN_LOG_FORMAT - Set it to json, to have JSON logs output. Default: text.
PASTEBIN_LOG_EXCLUDE - Set it to any regex that you needs to exclude from the logs, e.g. \/health|127.0.0.1 will exclude calls to /health endpoint, and or from IP 127.0.0.1. Default is not set, so that everything shown.
PASTEBIN_FILE_LOG - Set log file location to log all App output. Default is not set, it is logged to stdout. If you need log file, simply provide a path writable by user "nobody". Recommended is /app/data/pastebin.log.
PASTEBIN_DEFAULT_BURN - If enabled all pastes without burn=false will be saved to be viewed only once. You can still set burn=false via UI or CLI. Default: false.PASTEBIN_DEFAULT_TTL - Default expiration if none provided. Default: 0 (no expiration)PASTEBIN_MAX_TTL - Maximum allowed TTL. It is recommended to set this value for internet accessible sites. It is recommended to set this value if protected pastes are enabled. If set:
Supported Formats:
| Format | Example |
|---|---|
| Seconds | 3600 |
| Hours | 1h |
| Days | 1d |
| Months (30d) | 1mo |
PASTEBIN_MAX_PARALLEL_UPLOADS - Max amount of parallel POST requests. Default 20. Be aware that each requests needs memory. E.g. if PASTEBIN_MAX_PASTE_SIZE=5MB and PASTEBIN_MAX_PARALLEL_UPLOADS=20, that needs around 5*20*2,3 (roughly amount of modifications) = 230 Mb of RAM and with PASTEBIN_MAX_PASTE_SIZE=30MB around 1,5 GB of RAM.PASTEBIN_MAX_PASTE_SIZE - Max upload size. Default: 5MBSupported Formats:
| Format | Example |
|---|---|
| bytes | 3600 |
| Kilobytes | 1kb |
| Megabytes | 1mb |
| Gigabytes | 1gb |
PASTEBIN_SERVER_SIDE_ENCRYPTION_ENABLED- Enable server side encryption before to store the paste. Recommended on shared environments. Default false - disabled.PASTEBIN_SERVER_SIDE_ENCRYPTION_KEY- 32-byte base64 key (required if encryption enabled). You can generate Key with openssl, or directly with this container.openssl rand -base64 32
Or:
docker run -e GENERATE_KEY=true gas85/ownpastebin:latest
โ ๏ธ If you ever rotate the key or loose it, old pastes become permanently unreadable. There is no restore for it. โ ๏ธ
PASTEBIN_SLUG_LEN - Uniq URL Length. Default to 20. It is not recommended to go below this value to avoid possible collision (handled by storage) and Link guessing attack.PASTEBIN_PROTECTED_PASTE_ENABLED - enable support for protected pastes. They can be created with a flag protected=true and can be only removed by expiration time or burn option. It is recommended to set PASTEBIN_MAX_TTL this feature is enabled, otherwise it could result in pastes that live indefinitely. They can only be removed via direct database access. Default to false.PASTEBIN_EXPIRY_TIMES - You can set your own expiration timers list as <Name>:<Value in seconds>,. Where <Name> could be Never for never expired pastes, or X <label>, where X expiration time shown in UI and <label> could be one of Min/Hour/Day/Week/Month/Year. E.g. "Never:0,5 Min:300,1 Hour:3600,1 Day:86400,1 Week:604800" will produce following dropdown:
PASTEBIN_DATE_FORMAT - Text logs timestamp format. Disabled when logs format is set to json. Default: %Y-%m-%d %H:%M:%STZ - Timezone. Default Europe/ZurichPASTEBIN_THEME - Set custom theme as per W3.CSS Color Themesโ , add e.g. blue, teal, green, etc. Default theme used when not set.PASTEBIN_THEME_CUSTOM_CSS - Overrides Theme with your own CSS. Please use format as in a W3.CSS Color Themesโ .
This will overrule PASTEBIN_THEME, you should't use both. Default theme used when non of them set.
You can set it to e.g. w3-theme-l5 {color:#000 !important; background-color:#fff !important}.w3-theme-l3 {color:#000 !important; background-color:#f8f9fa !important}....PASTEBIN_COOKIE_URL - Set custom Cookie URL. This Application itself will not set any cookies, but if you are using this application as sub path to your domain or behind e.g. OAUTH2 Proxyโ they could set cookies and you will need to reference your cookie policy here. Default is not set.PASTEBIN_PRIVACY_URL - Set custom Privacy Policy URL if you need. Default is not set.PASTEBIN_CUSTOM_ICON - Set custom icon to your PASTEBIN_CUSTOM_URL if needed. You can set something from Font Awesomeโ free collection, e.g. fa-solid fa-question to set a โ. Default: fa-solid fa-question if PASTEBIN_CUSTOM_URL was set.PASTEBIN_CUSTOM_URL - Set custom URL if needed, works together with PASTEBIN_CUSTOM_ICON. Default is not set.| Config | Backend Used |
|---|---|
PASTEBIN_REDIS_URL | Valkey/Redis |
PASTEBIN_POSTGRES_URL | PostgreSQL |
| None set | SQLite |
You can still set custom SQLite DB location via PASTEBIN_SQLITE_PATH.
docker run -d \
--name pastebin \
-p 8080:8080 \
-v ./data:/app/data \
-e PASTEBIN_MAX_TTL=360d \
-e PASTEBIN_BASE_URL=http://localhost:8080 \
--restart always \
gas85/ownpastebin:latest
Please refer to docker-compose.ymlโ as example.
docker compose up -d
Please refer to k8s.ymlโ as example.
kubectl apply -f k8s.yml
You can build it from sources with following commands:
go mod download
CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w" -o pastebin .
Or use docker
docker build -t ownpastebin:latest .
You can perform local test automation with following command:
CGO_ENABLED=1 go test ./... -v
You can find API documentation under /swagger-ui e.g. https://sitnikov.eu/pastebin/swagger-uiโ
POST /Create a new paste.
application/jsonapplication/x-www-form-urlencodedmultipart/form-data--data-binary)| Name | Type | Description |
|---|---|---|
ttl | int | Time to live (seconds) |
protected | bool | Protected paste, will not be deleted upon request, only expiration time and / or burn can remove such kind of pastes |
burn | bool | Delete after first read |
encrypted | bool | Marks paste as client-side encrypted. It is only being used to give UI a trigger to offer Decryption directly in Browser. Otherwise encrypted data will be shown. |
curl "http://localhost:8080" --data-binary "@file.txt"
E.g. you can push all docker logs to the pastebin:
# As per https://wiki.sitnikov.eu/doku.php?id=howto:docker#push_all_docker_logs_to_the_pastebin
docker ps --format '{{.Names}}' | xargs -I {} sh -c 'docker logs --timestamps -tail 500 {} 2>&1 | sed "s/^/[{}] /"' | curl http://localhost:8080 --data-binary @-
curl "http://localhost:8080?burn=true&ttl=60" --data-binary "@file.txt"
curl "http://localhost:8080?burn=true&ttl=60&protected=true" --data-binary "@file.txt"
As Response you will get JSON with URL to the webUI for this paste and paste ID that you can use e.g. to call /raw or /download endpoint.
{
"url": "http://localhost:8080/abc123",
"id": "abc123",
"lang": "text"
}
GET /{paste_id}Returns HTML view.
curl http://localhost:8080/abc123
GET /raw/{paste_id}Returns plain text or binary-safe response.
curl http://localhost:8080/raw/abc123
GET /download/{paste_id}Forces file download.
curl http://localhost:8080/download/abc123
DELETE /{paste_id}curl -X DELETE http://localhost:8080/abc123
If burn=true:
404 Not Foundif protected=true:
403 Forbidden with paste is protected message413 Paste too large
403 Paste is protected
Example:
2026-03-25 09:55:57 - INFO - pastebin - access method=GET path=/ status=200 duration=1.077ms bytes=15044 ip=192.168.65.1:57801
{"level":"INFO","msg":{"bytes":14562,"duration":"710ยตs","ip":"192.168.65.1:59435","message":"access","method":"GET","path":"/","status":200},"time":"2026-04-27T20:13:34.986291506+02:00"}
static/en.json to any new language file you need.static/custom.js update const flags with new language.templates/index.html and templates/index_full.html add new language in i18n-dropdown div.This pastebin is designed to be:
Inspired by Pastebinโ .
Content type
Image
Digest
sha256:783105668โฆ
Size
14 MB
Last updated
1 day ago
docker pull gas85/ownpastebin