diff --git a/.prettierrc.json b/.prettierrc.json
new file mode 100644
index 0000000..aed6467
--- /dev/null
+++ b/.prettierrc.json
@@ -0,0 +1,8 @@
+{
+ "semi": true,
+ "trailingComma": "all",
+ "singleQuote": true,
+ "printWidth": 120,
+ "tabWidth": 2,
+ "endOfLine": "lf"
+}
diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml
index 81821ca..a5ff820 100644
--- a/.woodpecker/build.yml
+++ b/.woodpecker/build.yml
@@ -48,7 +48,7 @@ steps:
- go version
- just build-tag ${CI_COMMIT_TAG##v}
when:
- - event: ["tag"]
+ - event: ['tag']
branch:
- ${CI_REPO_DEFAULT_BRANCH}
@@ -92,7 +92,7 @@ steps:
- CI_BUILD_EVENT=${CI_BUILD_EVENT}
- CI_COMMIT_REF=${CI_COMMIT_REF}
when:
- - event: ["tag"]
+ - event: ['tag']
branch:
- ${CI_REPO_DEFAULT_BRANCH}
@@ -109,7 +109,7 @@ steps:
password:
from_secret: bot_token
when:
- - event: ["push"]
+ - event: ['push']
branch: ${CI_REPO_DEFAULT_BRANCH}
docker-tag:
@@ -119,11 +119,11 @@ steps:
registry: codeberg.org
dockerfile: Dockerfile
repo: codeberg.org/codeberg/pages-server
- tags: [latest, "${CI_COMMIT_TAG}"]
+ tags: [latest, '${CI_COMMIT_TAG}']
username:
from_secret: bot_user
password:
from_secret: bot_token
when:
- - event: ["push"]
+ - event: ['push']
branch: ${CI_REPO_DEFAULT_BRANCH}
diff --git a/.woodpecker/lint.yml b/.woodpecker/lint.yml
index 02d9ec8..3b269f6 100644
--- a/.woodpecker/lint.yml
+++ b/.woodpecker/lint.yml
@@ -24,3 +24,9 @@ steps:
- event: pull_request
- event: push
branch: renovate/*
+
+ prettier:
+ image: docker.io/woodpeckerci/plugin-prettier:0.1.0
+ depends_on: []
+ settings:
+ version: 3.2.5
diff --git a/FEATURES.md b/FEATURES.md
index 3d2f394..52b90e5 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -19,16 +19,16 @@ Redirects can be created with a `_redirects` file with the following format:
from to [status]
```
-* Lines starting with `#` are ignored
-* `from` - the path to redirect from (Note: repository and branch names are removed from request URLs)
-* `to` - the path or URL to redirect to
-* `status` - status code to use when redirecting (default 301)
+- Lines starting with `#` are ignored
+- `from` - the path to redirect from (Note: repository and branch names are removed from request URLs)
+- `to` - the path or URL to redirect to
+- `status` - status code to use when redirecting (default 301)
### Status codes
-* `200` - returns content from specified path (no external URLs) without changing the URL (rewrite)
-* `301` - Moved Permanently (Permanent redirect)
-* `302` - Found (Temporary redirect)
+- `200` - returns content from specified path (no external URLs) without changing the URL (rewrite)
+- `301` - Moved Permanently (Permanent redirect)
+- `302` - Found (Temporary redirect)
### Examples
diff --git a/README.md b/README.md
index f47a196..c23d86a 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
[![License: EUPL-1.2](https://img.shields.io/badge/License-EUPL--1.2-blue)](https://opensource.org/license/eupl-1-2/)
[![status-badge](https://ci.codeberg.org/api/badges/Codeberg/pages-server/status.svg)](https://ci.codeberg.org/Codeberg/pages-server)
-
+
Gitea lacks the ability to host static pages from Git.
@@ -21,19 +21,19 @@ and the [Codeberg Documentation](https://docs.codeberg.org/codeberg-pages/).
This is the new Codeberg Pages server, a solution for serving static pages from Gitea repositories.
Mapping custom domains is not static anymore, but can be done with DNS:
-1) add a `.domains` text file to your repository, containing the allowed domains, separated by new lines. The
-first line will be the canonical domain/URL; all other occurrences will be redirected to it.
+1. add a `.domains` text file to your repository, containing the allowed domains, separated by new lines. The
+ first line will be the canonical domain/URL; all other occurrences will be redirected to it.
-2) add a CNAME entry to your domain, pointing to `[[{branch}.]{repo}.]{owner}.codeberg.page` (repo defaults to
-"pages", "branch" defaults to the default branch if "repo" is "pages", or to "pages" if "repo" is something else.
-If the branch name contains slash characters, you need to replace "/" in the branch name to "~"):
- `www.example.org. IN CNAME main.pages.example.codeberg.page.`
+2. add a CNAME entry to your domain, pointing to `[[{branch}.]{repo}.]{owner}.codeberg.page` (repo defaults to
+ "pages", "branch" defaults to the default branch if "repo" is "pages", or to "pages" if "repo" is something else.
+ If the branch name contains slash characters, you need to replace "/" in the branch name to "~"):
+ `www.example.org. IN CNAME main.pages.example.codeberg.page.`
-3) if a CNAME is set for "www.example.org", you can redirect there from the naked domain by adding an ALIAS record
-for "example.org" (if your provider allows ALIAS or similar records, otherwise use A/AAAA), together with a TXT
-record that points to your repo (just like the CNAME record):
- `example.org IN ALIAS codeberg.page.`
- `example.org IN TXT main.pages.example.codeberg.page.`
+3. if a CNAME is set for "www.example.org", you can redirect there from the naked domain by adding an ALIAS record
+ for "example.org" (if your provider allows ALIAS or similar records, otherwise use A/AAAA), together with a TXT
+ record that points to your repo (just like the CNAME record):
+ `example.org IN ALIAS codeberg.page.`
+ `example.org IN TXT main.pages.example.codeberg.page.`
Certificates are generated, updated and cleaned up automatically via Let's Encrypt through a TLS challenge.
@@ -43,7 +43,8 @@ Certificates are generated, updated and cleaned up automatically via Let's Encry
## Deployment
-**Warning: Some Caveats Apply**
+**Warning: Some Caveats Apply**
+
> Currently, the deployment requires you to have some knowledge of system administration as well as understanding and building code,
> so you can eventually edit non-configurable and codeberg-specific settings.
> In the future, we'll try to reduce these and make hosting Codeberg Pages as easy as setting up Gitea.
@@ -74,7 +75,7 @@ and especially have a look at [this section of the haproxy.cfg](https://codeberg
- `ACME_API` (default: ): set this to to use invalid certificates without any verification (great for debugging).
ZeroSSL might be better in the future as it doesn't have rate limits and doesn't clash with the official Codeberg certificates (which are using Let's Encrypt), but I couldn't get it to work yet.
- `ACME_EMAIL` (default: `noreply@example.email`): Set the email sent to the ACME API server to receive, for example, renewal reminders.
-- `ACME_EAB_KID` & `ACME_EAB_HMAC` (default: don't use EAB): EAB credentials, for example for ZeroSSL.
+- `ACME_EAB_KID` & `ACME_EAB_HMAC` (default: don't use EAB): EAB credentials, for example for ZeroSSL.
- `ACME_ACCEPT_TERMS` (default: use self-signed certificate): Set this to "true" to accept the Terms of Service of your ACME provider.
- `ACME_USE_RATE_LIMITS` (default: true): Set this to false to disable rate limits, e.g. with ZeroSSL.
- `ENABLE_HTTP_SERVER` (default: false): Set this to true to enable the HTTP-01 challenge and redirect all other HTTP requests to HTTPS. Currently only works with port 80.
diff --git a/examples/haproxy-sni/README.md b/examples/haproxy-sni/README.md
index 8bb8f02..8165d6c 100644
--- a/examples/haproxy-sni/README.md
+++ b/examples/haproxy-sni/README.md
@@ -1,8 +1,9 @@
# HAProxy with SNI & Host-based rules
-This is a proof of concept, enabling HAProxy to use *either* SNI to redirect to backends with their own HTTPS certificates (which are then fully exposed to the client; HAProxy only proxies on a TCP level in that case), *as well as* to terminate HTTPS and use the Host header to redirect to backends that use HTTP (or a new HTTPS connection).
+This is a proof of concept, enabling HAProxy to use _either_ SNI to redirect to backends with their own HTTPS certificates (which are then fully exposed to the client; HAProxy only proxies on a TCP level in that case), _as well as_ to terminate HTTPS and use the Host header to redirect to backends that use HTTP (or a new HTTPS connection).
## How it works
+
1. The `http_redirect_frontend` is only there to listen on port 80 and redirect every request to HTTPS.
2. The `https_sni_frontend` listens on port 443 and chooses a backend based on the SNI hostname of the TLS connection.
3. The `https_termination_backend` passes all requests to a unix socket (using the plain TCP data).
@@ -11,6 +12,7 @@ This is a proof of concept, enabling HAProxy to use *either* SNI to redirect to
In the example (see [haproxy.cfg](haproxy.cfg)), the `pages_backend` is listening via HTTPS and is providing its own HTTPS certificates, while the `gitea_backend` only provides HTTP.
## How to test
+
```bash
docker-compose up &
./test.sh
diff --git a/examples/haproxy-sni/docker-compose.yml b/examples/haproxy-sni/docker-compose.yml
index 66ff52b..2cac2ad 100644
--- a/examples/haproxy-sni/docker-compose.yml
+++ b/examples/haproxy-sni/docker-compose.yml
@@ -1,22 +1,21 @@
-version: "3"
+version: '3'
services:
haproxy:
image: haproxy
- ports: ["443:443"]
+ ports: ['443:443']
volumes:
- - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- - ./dhparam.pem:/etc/ssl/dhparam.pem:ro
- - ./haproxy-certificates:/etc/ssl/private/haproxy:ro
+ - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
+ - ./dhparam.pem:/etc/ssl/dhparam.pem:ro
+ - ./haproxy-certificates:/etc/ssl/private/haproxy:ro
cap_add:
- - NET_ADMIN
+ - NET_ADMIN
gitea:
image: caddy
volumes:
- - ./gitea-www:/srv:ro
- - ./gitea.Caddyfile:/etc/caddy/Caddyfile:ro
+ - ./gitea-www:/srv:ro
+ - ./gitea.Caddyfile:/etc/caddy/Caddyfile:ro
pages:
image: caddy
volumes:
- - ./pages-www:/srv:ro
- - ./pages.Caddyfile:/etc/caddy/Caddyfile:ro
-
+ - ./pages-www:/srv:ro
+ - ./pages.Caddyfile:/etc/caddy/Caddyfile:ro
diff --git a/html/templates/error.html b/html/templates/error.html
index 6094a26..05a5d46 100644
--- a/html/templates/error.html
+++ b/html/templates/error.html
@@ -1,18 +1,12 @@
-
+
{{.StatusText}}
-
-
+
+
-