Skip to content

Commit 0932097

Browse files
authored
Merge pull request #332 from Cinzya/feature/healthcheck
2 parents 4cf145d + 29f72c4 commit 0932097

File tree

8 files changed

+110
-95
lines changed

8 files changed

+110
-95
lines changed

docs/.vitepress/config.mts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ export default defineConfig({
370370
{ text: 'Custom SSL Certificates', link: '/knowledge-base/proxy/traefik/custom-ssl-certs' },
371371
{ text: 'Dashboard', link: '/knowledge-base/proxy/traefik/dashboard' },
372372
{ text: 'Dynamic Configurations', link: '/knowledge-base/proxy/traefik/dynamic-config' },
373-
{ text: 'Healthcheck', link: '/knowledge-base/proxy/traefik/healthchecks' },
374373
{ text: 'Load Balancing', link: '/knowledge-base/proxy/traefik/load-balancing' },
375374
{ text: 'Redirects', link: '/knowledge-base/proxy/traefik/redirects' },
376375
{ text: 'Wildcard SSL Certificates', link: '/knowledge-base/proxy/traefik/wildcard-certs' },

docs/knowledge-base/environment-variables.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ description: "A guide how to use environment variables in Coolify."
44
---
55

66
# Environment Variables
7+
78
You can define environment variables for your resources, and they will be available in your application.
89

910
> Preview Deployments could have different environment variables, so you can test your application as a staging environment for example.
@@ -25,15 +26,19 @@ You can set shared variables on their respective pages.
2526
Then you can use these variables anywhere. For example: You defined `NODE_ENV` to `production`.
2627

2728
### Team Based
29+
2830
You can set them on the `Team` page and use it with <code v-pre>{{team.NODE_ENV}}</code>. Do not replace "team" with your actual team name.
2931

3032
### Project Based
33+
3134
You can set them on the `Projects` page, under the gear icon and use it with <code v-pre>{{project.NODE_ENV}}</code>. Do not replace "project" with your actual project name.
3235

3336
### Environment Based
37+
3438
You can set them on the `Environments` page (select a `Project`), under the gear icon and use it with <code v-pre>{{environment.NODE_ENV}}</code> Do not replace "environment" with your actual environment name.
3539

3640
#### Using Shared Variables in Compose File
41+
3742
If you want to use the environment variables in your compose file, you can do so by using the following syntax:
3843

3944
```bash
@@ -49,41 +54,50 @@ NODE_ENV={{team.NODE_ENV}}
4954

5055
## Predefined Variables
5156

52-
Coolify predefines some variables for you, so you can use them in your application. All you need to do is to add an environment variable like this to your application.
57+
Coolify predefines some variables for you, so you can use them in your application or service. All you need to do is to add an environment variable like this to your application or service.
5358

5459
```bash
5560
# For example, you can use this variable in your application
5661
MY_VARIABLE=$SOURCE_COMMIT
5762
# You will have the commit hash of the source code in your application as an environment variable in MY_VARIABLE
5863
```
5964

60-
### `COOLIFY_FQDN`
65+
### Application Variables
66+
67+
#### `COOLIFY_FQDN`
6168

6269
Fully qualified domain name(s) of the application.
6370

64-
### `COOLIFY_URL`
71+
#### `COOLIFY_URL`
6572

6673
URL(s) of the application.
6774

68-
### `COOLIFY_BRANCH`
75+
#### `COOLIFY_BRANCH`
6976

7077
Branch name of the source code.
7178

72-
### `COOLIFY_RESOURCE_UUID`
79+
#### `COOLIFY_RESOURCE_UUID`
7380

7481
Unique resource identifier generated by Coolify.
7582

76-
### `COOLIFY_CONTAINER_NAME`
83+
#### `COOLIFY_CONTAINER_NAME`
7784

7885
Name of the container generated by Coolify.
7986

80-
### `SOURCE_COMMIT`
87+
#### `SOURCE_COMMIT`
8188

8289
Commit hash of the source code.
8390

84-
### `PORT`
91+
#### `PORT`
8592

8693
If not set: it is set to the `Port Exposes`'s first port.
8794

88-
### `HOST`
95+
#### `HOST`
96+
8997
If not set: it is set to `0.0.0.0`
98+
99+
### Service Stack Variables
100+
101+
#### `SERVICE_NAME_<SERVICE>`
102+
103+
The service name of a given service in the stack. For example, if you have a service named `web`, you can access it with `SERVICE_NAME_WEB`. Useful for preview deployments where service names will vary.

docs/knowledge-base/health-checks.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,49 @@
11
---
22
title: Health checks
3+
description: Learn how to manage health checks in Coolify for your applications and services.
4+
keywords: ["Healthchecks", "Not Found", "No available server", "404", "503"]
35
---
46

57
# Health checks
6-
Health checks are important, but not mandatory for your application. It is a way to check if your application is started properly. Coolify provides a way to configure health checks for your application.
78

8-
## How it works
9+
Health checks are a way to ensure that your applications and services are running correctly. They allow Coolify to monitor the health of your resources and ensure that traffic is only routed to healthy instances. This for example important for [Rolling Updates](/knowledge-base/rolling-updates) to work correctly.
910

10-
If you set a health check, Coolify (and integrated proxy) will check the health of your application by sending a request to the health check endpoint.
11+
## Traefik
1112

12-
The integrated proxy only forwards the request to your application if the health check is successful. If the health check fails, the proxy will return a 502 Bad Gateway error.
13+
When using Traefik as the reverse proxy, health checks are an integral part of how it routes traffic to your resources.
1314

14-
## What if I do not set a health check?
15+
### Enabled
1516

16-
You get a warning next to your application's status. It is not mandatory, but it is recommended to set a health check.
17-
The integrated proxy will forward the request to your application without checking the health.
17+
If your resource has health checks _enabled_, Traefik will only route traffic to it if the health check passes. If the health check fails, Traefik will not route traffic to the resource.
1818

19-
::: warning Caution!
20-
Health checks run inside your container, so you need to have either `curl` or `wget` installed on your container. You can use an docker image that already includes `curl/wget` or add it to your Dockerfile yourself.
19+
**It will cause the resource to return a `404 Not Found` or `No available server` error.**
2120

22-
Without one of these packages, health checks will always fail and mark your container as unhealthy, which will cause the deployment to fail due to the failing health check.
23-
:::
21+
### Disabled
22+
23+
If your resource has health checks _disabled_, Traefik will route traffic to it regardless of the health check status.
24+
25+
## Configure Health checks
26+
27+
### Applications
28+
29+
There are two ways to configure health checks for your applications:
30+
31+
<ZoomableImage src="/docs/images/knowledge-base/resources/healthcheck.webp" />
32+
33+
1. **Using the UI**: You can set up health checks directly in the Coolify UI when creating or editing an application. You can specify the path to check, the expected response code, and the interval for checking. It will be required that the container has either `curl` or `wget` installed to perform the health checks.
2434

35+
2. **Using the Dockerfile**: You can also define health checks in your Dockerfile using the [HEALTHCHECK](https://docs.docker.com/reference/dockerfile/#healthcheck) instruction. This allows you to specify how the health check should be performed, including the command to run and the expected response.
36+
37+
If there are healthchecks both in the UI and in the Dockerfile defined and enabled, the Dockerfile will take precedence.
38+
39+
### Service Stacks
40+
41+
Services or Applications that use the [Docker Compose Build Pack](/builds/packs/docker-compose) require their health checks to be defined in the `Dockerfile` of each service, or in their `docker-compose.y[a]ml` file using the [healthcheck](https://docs.docker.com/reference/compose-file/services/#healthcheck) attribute.
42+
43+
::: tip When to use health checks?
44+
It is recommended to enable health checks for all your resources. This way, you can ensure that only healthy resources are receiving traffic.
45+
46+
But if you cannot set up health checks for some reason, you can disable them.
47+
48+
Just be aware that if the resource is unhealthy, it will still receive traffic.
49+
:::

docs/knowledge-base/proxy/traefik/healthchecks.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

docs/knowledge-base/proxy/traefik/overview.md

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,51 @@ title: "Traefik Overview"
33
---
44

55
# Traefik Proxy
6-
[Traefik ↗](https://traefik.io/) is a modern, open-source reverse proxy and load balancer designed to handle incoming requests and route them to the appropriate services. It’s widely used in the container ecosystem, making it a perfect fit for projects running on Coolify.
76

8-
By default, Coolify uses Traefik as its proxy, enabling easy management of routing, SSL certificates, and more, without requiring deep technical expertise.
7+
[Traefik ↗](https://traefik.io/) is a modern, open-source reverse proxy and load balancer designed to handle incoming requests and route them to the appropriate services. It’s widely used in the container ecosystem, making it a perfect fit for projects running on Coolify.
98

9+
By default, Coolify uses Traefik as its proxy, enabling easy management of routing, SSL certificates, and more, without requiring deep technical expertise.
1010

11-
## Why Use Traefik?
12-
- Dynamically manages routing between your apps and the internet.
13-
- Integrates seamlessly with container orchestrators like Docker or Kubernetes.
14-
- Simplifies SSL/TLS certificate management, including support for [Let's Encrypt ↗](https://letsencrypt.org/).
15-
- Offers advanced features like load balancing and middleware for fine-grained control.
16-
- Comes with a built-in dashboard for monitoring routes and configurations.
11+
## Why Use Traefik?
1712

13+
- Dynamically manages routing between your apps and the internet.
14+
- Integrates seamlessly with container orchestrators like Docker or Kubernetes.
15+
- Simplifies SSL/TLS certificate management, including support for [Let's Encrypt ↗](https://letsencrypt.org/).
16+
- Offers advanced features like load balancing and middleware for fine-grained control.
17+
- Comes with a built-in dashboard for monitoring routes and configurations.
1818

19-
## When Not to Use Traefik?
20-
- If you need complete control over every aspect of your reverse proxy.
21-
- If you prefer using another reverse proxy solution like [NGINX ↗](https://nginx.org/en/).
22-
- If you have highly customized or complex routing rules that Traefik might not fully support.
19+
## When Not to Use Traefik?
2320

21+
- If you need complete control over every aspect of your reverse proxy.
22+
- If you prefer using another reverse proxy solution like [NGINX ↗](https://nginx.org/en/).
23+
- If you have highly customized or complex routing rules that Traefik might not fully support.
2424

25-
## Ways to Use Traefik with Coolify
26-
Coolify automatically configures Traefik as your proxy. However, you can customize and extend Traefik's functionality based on your needs.
25+
## Ways to Use Traefik with Coolify
2726

28-
Below are some of the key features and ways you can use Traefik with Coolify:
27+
Coolify automatically configures Traefik as your proxy. However, you can customize and extend Traefik's functionality based on your needs.
2928

30-
1. [Basic Authentication](/knowledge-base/proxy/traefik/basic-auth) -> Add username and password protection to your applications.
29+
Below are some of the key features and ways you can use Traefik with Coolify:
3130

32-
2. [Custom SSL Certificates](/knowledge-base/proxy/traefik/custom-ssl-certs) -> Use your own SSL certificates instead of automatically generated ones.
31+
1. [Basic Authentication](/knowledge-base/proxy/traefik/basic-auth) -> Add username and password protection to your applications.
3332

34-
3. [Dashboard](/knowledge-base/proxy/traefik/dashboard) -> Enable Traefik’s built-in dashboard for real-time monitoring and insights.
33+
2. [Custom SSL Certificates](/knowledge-base/proxy/traefik/custom-ssl-certs) -> Use your own SSL certificates instead of automatically generated ones.
3534

36-
4. [Dynamic Configuration](/knowledge-base/proxy/traefik/dynamic-config) -> Manage dynamic configuration changes like routing rules or middlewares.
35+
3. [Dashboard](/knowledge-base/proxy/traefik/dashboard) -> Enable Traefik’s built-in dashboard for real-time monitoring and insights.
3736

38-
5. [Health Checks](/knowledge-base/proxy/traefik/healthchecks) -> Configure health checks to ensure your applications are running smoothly.
37+
4. [Dynamic Configuration](/knowledge-base/proxy/traefik/dynamic-config) -> Manage dynamic configuration changes like routing rules or middlewares.
3938

40-
6. [Load Balancing](/knowledge-base/proxy/traefik/load-balancing) -> Distribute traffic across multiple app instances for better performance.
39+
5. [Health Checks](/knowledge-base/health-checks) -> Configure health checks to ensure your applications are running smoothly.
4140

42-
7. [Redirects](/knowledge-base/proxy/traefik/redirects) -> Set up HTTP-to-HTTPS redirection or create specific URL redirects.
41+
6. [Load Balancing](/knowledge-base/proxy/traefik/load-balancing) -> Distribute traffic across multiple app instances for better performance.
4342

44-
8. [Wildcard Certificates](/knowledge-base/proxy/traefik/wildcard-certs) -> Secure multiple subdomains with a single SSL certificate.
43+
7. [Redirects](/knowledge-base/proxy/traefik/redirects) -> Set up HTTP-to-HTTPS redirection or create specific URL redirects.
44+
45+
8. [Wildcard Certificates](/knowledge-base/proxy/traefik/wildcard-certs) -> Secure multiple subdomains with a single SSL certificate.
4546

4647
---
4748

4849
::: danger CAUTION!
49-
**Do not make changes to Traefik's configuration unless you are sure of what you are doing. Incorrect settings can make your entire application inaccessible..**
50+
**Do not make changes to Traefik's configuration unless you are sure of what you are doing. Incorrect settings can make your entire application inaccessible..**
5051

51-
**We highly recommend testing any changes in a development environment before applying them to production.**
52-
:::
52+
**We highly recommend testing any changes in a development environment before applying them to production.**
53+
:::
Binary file not shown.
Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
---
2-
title: Bad Gateway Error
2+
title: Bad Gateway Error
33
---
44

55
# Bad Gateway Error
6+
67
If your deployed application **maybe** works when you access it via your server’s IP address and port but shows a **Bad Gateway** error on your domain, the issue is most often due to misconfigured port settings, incorrect host mapping, or your app listening only on localhost.
78

89
## What’s an Application and What's a Service?
10+
911
- **Application:** An Application is deployed by you using a Git repository or any deployment option **except** the one-click service.
1012

1113
- **Service:** A Service is an app deployed using a Compose file or the one-click service on Coolify. These deployments may have different network settings and UI sections (for example, you might not see the Network section in your UI).
1214

13-
1415
## Symptoms
15-
- The application **maybe** accessible via the server IP with a port number but not via the domain.
16-
- You might also run into a **No Available Server** error.
1716

17+
- The application **maybe** accessible via the server IP with a port number but not via the domain.
1818

1919
## Diagnosis
20-
- **Port Configuration:**
21-
- **Applications:** Make sure the port your app is listening on is correctly entered in the **Port Exposes** field on the Coolify dashboard.
20+
21+
- **Port Configuration:**
22+
23+
- **Applications:** Make sure the port your app is listening on is correctly entered in the **Port Exposes** field on the Coolify dashboard.
2224
- **Services:** Check that your Compose or one-click service configuration has the appropriate network configuration.
2325

24-
- **Host Mapping:**
26+
- **Host Mapping:**
27+
2528
- **Applications:** Verify that the application’s port is not incorrectly mapped to the host system.
2629
- **Services:** Confirm that any port mapping in your Compose file or service configuration aligns with the proxy routing requirements.
2730

@@ -31,28 +34,27 @@ If your deployed application **maybe** works when you access it via your server
3134

3235
- **Container Status:** Check the status of the container where your app or service is running. Is it unhealthy? Stuck at Starting? A failing health check might be the reason.
3336

34-
3537
## Solution
36-
- **Update Port Settings:** Enter the correct port number in the **Port Exposes** field on the Coolify dashboard and restart your app.
37-
38+
39+
- **Update Port Settings:** Enter the correct port number in the **Port Exposes** field on the Coolify dashboard and restart your app.
40+
3841
<ZoomableImage src="/docs/images/troubleshoot/applications/bad-gateway/1.webp" />
3942

40-
- **Remove Host Port Mapping:** If the port is mapped to the host system, remove the mapping so the proxy can route traffic correctly, then restart your app.
41-
43+
- **Remove Host Port Mapping:** If the port is mapped to the host system, remove the mapping so the proxy can route traffic correctly, then restart your app.
44+
4245
<ZoomableImage src="/docs/images/troubleshoot/applications/bad-gateway/2.webp" />
4346

44-
- **Adjust Listening Address:** Change your application so it listens on all network interfaces (`0.0.0.0`) instead of just `localhost`.
45-
47+
- **Adjust Listening Address:** Change your application so it listens on all network interfaces (`0.0.0.0`) instead of just `localhost`.
48+
4649
<ZoomableImage src="/docs/images/troubleshoot/applications/bad-gateway/3.webp" />
4750

4851
- **Correct Domain URL:** Add the correct port number at the end of your domain URL if needed, and restart your application.
49-
50-
<ZoomableImage src="/docs/images/troubleshoot/applications/bad-gateway/4.webp" />
5152

52-
- **Restart Container / Check Logs:** Restart the container or check its logs to diagnose the issue. Often, a failing health check might be the problem, and removing the health check could fix it.
53-
54-
<ZoomableImage src="/docs/images/troubleshoot/applications/bad-gateway/5.webp" />
53+
<ZoomableImage src="/docs/images/troubleshoot/applications/bad-gateway/4.webp" />
5554

55+
- **Restart Container / Check Logs:** Restart the container or check its logs to diagnose the issue.
56+
<ZoomableImage src="/docs/images/troubleshoot/applications/bad-gateway/5.webp" />
5657

5758
## Support
58-
If these steps don’t solve the issue, consider reaching out for further assistance by joining our [Discord community ↗](https://coolify.io/discord) and sharing your app logs, coolify proxy logs, configuration screenshots, and details of the troubleshooting steps you’ve already tried.
59+
60+
If these steps don’t solve the issue, consider reaching out for further assistance by joining our [Discord community ↗](https://coolify.io/discord) and sharing your app logs, coolify proxy logs, configuration screenshots, and details of the troubleshooting steps you’ve already tried.

0 commit comments

Comments
 (0)