From 0d7cd64eef4f2820c83ab328826468fb2dc489b6 Mon Sep 17 00:00:00 2001 From: Luck Date: Sun, 23 Feb 2025 15:18:45 +0000 Subject: [PATCH] Update self-hosting instructions --- README.md | 21 +++-------------- docker-compose.yml | 6 +++-- docker/nginx.conf | 2 +- docker/reverseproxy-nginx.conf | 42 +++++++++++++++++----------------- 4 files changed, 29 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index f8c99be..bf4102b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **paste is a simple web app for writing & sharing code.** It's my own take on conventional pastebin sites like _pastebin.com_ or _hastebin_. -Anyone can use paste! The official/public instance can be accessed using the endpoints listed below, but you can also [host your own](#host-your-own) if you like! +Anyone can use paste! The official/public instance can be accessed using the endpoints listed below, but you can also [host your own](#self-hosting) if you like! ##### 1) In a Web Browser Just go to https://pastes.dev! @@ -90,28 +90,13 @@ The API is powered by the [bytebin](https://github.com/lucko/bytebin) service, s ___ -### Host your own +### Self-hosting -It's quite simple to host your own version. +The easiest way to self-host is using Docker (& Docker Compose). You can run the following commands to get started: ```bash git clone https://github.com/lucko/paste cd paste -yarn install - -# Outputs html/css/js files to /build -yarn build - -# Start a webserver for testing/development -yarn start -``` - -You can then follow the [create-react-app deployment documentation](https://create-react-app.dev/docs/deployment/) for how to host the build output. I personally recommend deploying to the cloud using a service like Netlify instead of hosting on your own webserver. - -If you really want to self-host (including the bytebin data storage part), I suggest using Docker: - -```bash -git clone https://github.com/lucko/paste docker compose up -d ``` diff --git a/docker-compose.yml b/docker-compose.yml index a29456a..80f9322 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,10 @@ -version: '3.8' - services: + + # frontend service paste: image: ghcr.io/lucko/paste + # backend service bytebin: image: ghcr.io/lucko/bytebin volumes: @@ -11,6 +12,7 @@ services: environment: BYTEBIN_MISC_KEYLENGTH: 5 + # reverse proxy nginx: image: nginx:alpine command: ['nginx', '-g', 'daemon off;'] diff --git a/docker/nginx.conf b/docker/nginx.conf index 0afd2a7..678f13b 100644 --- a/docker/nginx.conf +++ b/docker/nginx.conf @@ -15,4 +15,4 @@ server { location ~ \.(?!html) { try_files $uri =404; } -} \ No newline at end of file +} diff --git a/docker/reverseproxy-nginx.conf b/docker/reverseproxy-nginx.conf index 017ba9c..d87095b 100644 --- a/docker/reverseproxy-nginx.conf +++ b/docker/reverseproxy-nginx.conf @@ -1,29 +1,29 @@ -# nginx reverse proxy configuration for paste+bytebin +# nginx reverse proxy configuration for paste frontend & bytebin backend server { listen 80 default_server; - # paste app + # proxy / path to paste frontend location / { - 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-Host $server_name; + 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-Host $server_name; - proxy_pass http://paste; - } + proxy_pass http://paste; + } - # disable bytebin frontend - location = /data/ { - return 404; - } + # disable bytebin frontend + location = /data/ { + return 404; + } - # proxy /data endpoint to bytebin - location /data/ { - 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-Host $server_name; + # proxy /data path to bytebin backend + location /data/ { + 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-Host $server_name; - proxy_pass http://bytebin:8080/; - } -} \ No newline at end of file + proxy_pass http://bytebin:8080/; + } +}