Self-hosted pastebin powered by Git, open-source alternative to Github Gist.
Find a file
2023-09-04 11:11:54 +02:00
.github/workflows Remove Dev Docker image (#80) 2023-07-17 04:16:08 +02:00
docker Fixes unable to access '/root/.config/git/attributes': Permission denied (#71) 2023-06-25 11:40:28 +02:00
internal Run git gc for repositories (#90) 2023-09-04 11:11:54 +02:00
public Tweaked project structure (#88) 2023-09-03 00:30:57 +02:00
templates Run git gc for repositories (#90) 2023-09-04 11:11:54 +02:00
.dockerignore Better build/watch 2023-04-06 13:55:04 +02:00
.gitattributes Tweaked project structure (#88) 2023-09-03 00:30:57 +02:00
.gitignore Better build/watch 2023-04-06 13:55:04 +02:00
CHANGELOG.md v1.4.2 2023-07-17 04:28:13 +02:00
config.yml Sqlite journal mode (#54) 2023-06-09 15:25:41 +02:00
Dockerfile Customise UID/GID for Docker (#63) 2023-06-18 12:50:36 +02:00
go.mod Update go module name 2023-05-15 21:07:29 +02:00
go.sum Bump golang.org/x/net from 0.4.0 to 0.7.0 2023-05-06 01:08:12 +00:00
LICENSE Initial commit 2023-03-14 16:22:52 +01:00
Makefile Tweaked project structure (#88) 2023-09-03 00:30:57 +02:00
opengist.go Tweaked project structure (#88) 2023-09-03 00:30:57 +02:00
package-lock.json Bump vite from 4.2.1 to 4.2.3 (#49) 2023-06-06 12:01:06 +02:00
package.json Bump vite from 4.2.1 to 4.2.3 (#49) 2023-06-06 12:01:06 +02:00
postcss.config.js Optimize assets 2023-03-23 16:00:48 +01:00
README.md Added private visibility 2023-09-02 03:58:37 +02:00
tailwind.config.js Light mode (#38) 2023-05-27 13:58:08 +02:00
tsconfig.json Convert Javascript to Typescript 2023-04-03 23:37:54 +02:00
vite.config.js Create admin settings and moved signup disable setting there 2023-04-17 00:17:06 +02:00
watch.sh Better build/watch 2023-04-06 13:55:04 +02:00

Opengist

GitHub release (latest SemVer) License GitHub Workflow Status Go Report Card

A self-hosted pastebin powered by Git. Try it here.

Features

  • Create public, unlisted or private snippets
  • Clone / Pull / Push snippets via Git over HTTP or SSH
  • Revisions history
  • Syntax highlighting ; markdown & CSV support
  • Like / Fork snippets
  • Search for snippets ; browse users snippets, likes and forks
  • Editor with indentation mode & size ; drag and drop files
  • Download raw files or as a ZIP archive
  • OAuth2 login with GitHub and Gitea
  • Avatars via Gravatar or OAuth2 providers
  • Light/Dark mode
  • Responsive UI
  • Enable or disable signups
  • Restrict or unrestrict snippets visibility to anonymous users
  • Admin panel : delete users/gists; clean database/filesystem by syncing gists
  • SQLite database
  • Logging
  • Docker support

Todo

  • Translation
  • Code/text search
  • Embed snippets
  • Tests
  • Filesystem/Redis support for user sessions
  • Have a cool logo

Install

With Docker

Docker images are available for each release :

docker pull ghcr.io/thomiceli/opengist:1.4

It can be used in a docker-compose.yml file :

  1. Create a docker-compose.yml file with the following content
  2. Run docker compose up -d
  3. Opengist is now running on port 6157, you can browse http://localhost:6157
version: "3"

services:
  opengist:
    image: ghcr.io/thomiceli/opengist:1.4
    container_name: opengist
    restart: unless-stopped
    ports:
      - "6157:6157" # HTTP port
      - "2222:2222" # SSH port, can be removed if you don't use SSH
    volumes:
      - "$HOME/.opengist:/opengist"

You can define which user/group should run the container and own the files by setting the UID and GID environment variables :

services:
  opengist:
    # ...
    environment:
      UID: 1001
      GID: 1001

From source

Requirements : Git (2.20+), Go (1.19+), Node.js (16+)

git clone https://github.com/thomiceli/opengist
cd opengist
make
./opengist

Opengist is now running on port 6157, you can browse http://localhost:6157

Configuration

Opengist provides flexible configuration options through either a YAML file and/or environment variables. You would only need to specify the configuration options you want to change — for any config option left untouched, Opengist will simply apply the default values.

Configuration option list
YAML Config Key Environment Variable Default value Description
log-level OG_LOG_LEVEL warn Set the log level to one of the following: trace, debug, info, warn, error, fatal, panic.
external-url OG_EXTERNAL_URL none Public URL for the Git HTTP/SSH connection. If not set, uses the URL from the request.
opengist-home OG_OPENGIST_HOME home directory Path to the directory where Opengist stores its data.
db-filename OG_DB_FILENAME opengist.db Name of the SQLite database file.
sqlite.journal-mode OG_SQLITE_JOURNAL_MODE WAL Set the journal mode for SQLite. More info here
http.host OG_HTTP_HOST 0.0.0.0 The host on which the HTTP server should bind.
http.port OG_HTTP_PORT 6157 The port on which the HTTP server should listen.
http.git-enabled OG_HTTP_GIT_ENABLED true Enable or disable git operations (clone, pull, push) via HTTP. (true or false)
http.tls-enabled OG_HTTP_TLS_ENABLED false Enable or disable TLS for the HTTP server. (true or false)
http.cert-file OG_HTTP_CERT_FILE none Path to the TLS certificate file if TLS is enabled.
http.key-file OG_HTTP_KEY_FILE none Path to the TLS key file if TLS is enabled.
ssh.git-enabled OG_SSH_GIT_ENABLED true Enable or disable git operations (clone, pull, push) via SSH. (true or false)
ssh.host OG_SSH_HOST 0.0.0.0 The host on which the SSH server should bind.
ssh.port OG_SSH_PORT 2222 The port on which the SSH server should listen.
ssh.external-domain OG_SSH_EXTERNAL_DOMAIN none Public domain for the Git SSH connection, if it has to be different from the HTTP one. If not set, uses the URL from the request.
ssh.keygen-executable OG_SSH_KEYGEN_EXECUTABLE ssh-keygen Path to the SSH key generation executable.
github.client-key OG_GITHUB_CLIENT_KEY none The client key for the GitHub OAuth application.
github.secret OG_GITHUB_SECRET none The secret for the GitHub OAuth application.
gitea.client-key OG_GITEA_CLIENT_KEY none The client key for the Gitea OAuth application.
gitea.secret OG_GITEA_SECRET none The secret for the Gitea OAuth application.
gitea.url OG_GITEA_URL https://gitea.com/ The URL of the Gitea instance.

Configuration via YAML file

The configuration file must be specified when launching the application, using the --config flag followed by the path to your YAML file.

./opengist --config /path/to/config.yml

You can start by copying and/or modifying the provided config.yml file.

Configuration via Environment Variables

Usage with Docker Compose :

services:
  opengist:
    # ...
    environment:
      OG_LOG_LEVEL: "info"
      # etc.

Usage via command line :

OG_LOG_LEVEL=info ./opengist

Administration

Use Nginx as a reverse proxy

Configure Nginx to proxy requests to Opengist. Here is an example configuration file :

server {
    listen 80;
    server_name opengist.example.com;

    location / {
        proxy_pass http://127.0.0.1:6157;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Then run :

service nginx restart

Use Fail2ban

Fail2ban can be used to ban IPs that try to bruteforce the login page. Log level must be set at least to warn.

Add this filter in etc/fail2ban/filter.d/opengist.conf :

[Definition]
failregex =  Invalid .* authentication attempt from <HOST>
ignoreregex =

Add this jail in etc/fail2ban/jail.d/opengist.conf :

[opengist]
enabled = true
filter = opengist
logpath = /home/*/.opengist/log/opengist.log
maxretry = 10
findtime = 3600
bantime = 600
banaction = iptables-allports
port = anyport

Then run

service fail2ban restart

Configure OAuth

Opengist can be configured to use OAuth to authenticate users, with GitHub or Gitea.

Integrate Github
  • Add a new OAuth app in your Github account settings
  • Set 'Authorization callback URL' to http://opengist.domain/oauth/github/callback
  • Copy the 'Client ID' and 'Client Secret' and add them to the configuration :
    github.client-key: <key>
    github.secret: <secret>
    
Integrate Gitea
  • Add a new OAuth app in Application settings from the Gitea instance
  • Set 'Redirect URI' to http://opengist.domain/oauth/gitea/callback
  • Copy the 'Client ID' and 'Client Secret' and add them to the configuration :
    gitea.client-key: <key>
    gitea.secret: <secret>
    # URL of the Gitea instance. Default: https://gitea.com/
    gitea.url: http://localhost:3000
    

License

Opengist is licensed under the AGPL-3.0 license.