|
1 | 1 | # Traefik-Proxy - with additional Cloudflare support |
2 | 2 |
|
3 | | -Traefik reverse proxy that (optionally) supports for Cloudflare and traefik hub. |
| 3 | +This repository provides a configuration for setting up Traefik as a reverse proxy for websites. |
| 4 | +It supports optionally a Cloudflare integration, and can optionally be coupled with a [authentik server](https://github.com/erkenes/docker-authentik) for user authentication. |
4 | 5 |
|
5 | | -## Installation |
| 6 | +## Prerequisites |
6 | 7 |
|
7 | | -Update the `.env` file to your purposes and then run |
| 8 | +Before you begin, ensure you have the following prerequisites: |
8 | 9 |
|
9 | | -```shell |
10 | | -docker compose up -d |
| 10 | +- [Docker](https://www.docker.com/) installed and configured on your server. |
| 11 | +- [Docker Compose](https://docs.docker.com/compose/install/) installed. |
| 12 | +- A registered domain name for your websites. |
| 13 | +- (Optional) A [Cloudflare](https://www.cloudflare.com/) account with an API key and email address if you plan to use Cloudflare. |
| 14 | + |
| 15 | +## Getting Started |
| 16 | + |
| 17 | +1. Clone this repository to your server: |
| 18 | + ```shell |
| 19 | + git clone https://github.com/erkenes/docker-traefik.git |
| 20 | + ``` |
| 21 | + |
| 22 | +2. Navigate to the repository directory: |
| 23 | + ```shell |
| 24 | + cd traefik-reverse-proxy |
| 25 | + ``` |
| 26 | + |
| 27 | +3. Create a `.env` file and configure your settings. You can use the provided `.env.example` |
| 28 | + ```shell |
| 29 | + cp .env.example .env |
| 30 | + ``` |
| 31 | + |
| 32 | +4. Change the root domain in the `.env` file to match your domain. Traefik will be available with `trafik.ROOT_DOMAIN_NAME`. |
| 33 | + You also have to change the root domain in the file [AppData/traefik-proxy/traefik.yml](AppData/traefik-proxy/traefik.yml) |
| 34 | + ```yaml |
| 35 | + entryPoints: |
| 36 | + https: |
| 37 | + http: |
| 38 | + tls: |
| 39 | + domains: |
| 40 | + # ToDo: Replace domain |
| 41 | + - main: 'traefik.local.dev' |
| 42 | + sans: |
| 43 | + - '*.local.dev' |
| 44 | + ``` |
| 45 | +
|
| 46 | +5. Start Traefik |
| 47 | + ```shell |
| 48 | + docker compose -f docker-compose.yml up -d |
| 49 | + ``` |
| 50 | + |
| 51 | +6. Your Traefik reverse proxy is now up and running, ready to route incoming traffic to your web services. |
| 52 | + |
| 53 | +## Optional Cloudflare Integration |
| 54 | + |
| 55 | +You have to follow the upper instructions first. |
| 56 | + |
| 57 | +1. Add your cloudflare api credentials to the secret files |
| 58 | + - `secrets/cf_api_key` for the api key |
| 59 | + - `secrets/cf_email` for your email address |
| 60 | + |
| 61 | +2. Start Traefik |
| 62 | + ```shell |
| 63 | + docker compose -f docker-compose.cloudflare.yml up -d |
| 64 | + ``` |
| 65 | + |
| 66 | +3. Your Traefik reverse proxy is now up and running, ready to route incoming traffic to your web services. |
| 67 | + |
| 68 | +## Optional Authentication Server |
| 69 | + |
| 70 | +If you wish to use an authentication server for user authentication, refer to the documentation of [this repository](https://github.com/erkenes/docker-authentik) for setup instructions. |
| 71 | + |
| 72 | +## Usage |
| 73 | + |
| 74 | +o use this Traefik reverse proxy, configure your web services to include the appropriate labels in their Docker Compose files. |
| 75 | +Consult the Traefik documentation for details on how to configure routing and SSL certificates. |
| 76 | + |
| 77 | +```yaml |
| 78 | +version: '3.9' |
| 79 | +services: |
| 80 | + whoami: |
| 81 | + image: traefik/whoami |
| 82 | + networks: |
| 83 | + - traefik-proxy |
| 84 | + labels: |
| 85 | + - "traefik.enable=true" |
| 86 | + ## HTTP Routers |
| 87 | + - "traefik.http.routers.whoami-rtr.rule=Host(`whoami.$DOMAIN`)" |
| 88 | + - "traefik.http.routers.whoami-rtr.entrypoints=https" |
| 89 | + - "traefik.http.routers.whoami-rtr.tls=true" |
| 90 | +networks: |
| 91 | + traefik-proxy: |
| 92 | + external: true |
11 | 93 | ``` |
12 | 94 |
|
| 95 | +## Troubleshooting |
| 96 | +
|
| 97 | +If you encounter issues or need further assistance, please check the logs of the Traefik container for error messages. |
| 98 | +Additionally, refer to the documentation for Traefik for detailed configuration options and troubleshooting tips. |
| 99 | +
|
| 100 | +## License |
| 101 | +
|
| 102 | +This project is licensed under the [MIT License](LICENSE). |
| 103 | +
|
| 104 | +## Acknowledgments |
| 105 | +
|
| 106 | +- [Traefik](https://traefik.io/): The reverse proxy and load balancer used to manage web traffic. |
| 107 | +
|
| 108 | +## Contributing |
| 109 | +
|
| 110 | +Contributions are welcome! If you have any improvements, bug fixes, or feature requests, please open an issue or submit a pull request. |
| 111 | +
|
| 112 | +--- |
| 113 | +
|
| 114 | +Happy proxying! |
| 115 | +
|
| 116 | +--- |
| 117 | +
|
13 | 118 | ## Use a custom local certificate |
14 | 119 |
|
15 | 120 | Install the RootCA from the directory `certs`. The wildcard domain `*.local.dev` and `local.dev` are now valid. |
|
0 commit comments