1

I want to use Coolify with CloudFlare Tunnels, so all my apps will be public using https domains, e.g. https://test.mydomain.com

I followed the steps mentioned in docs in order to have a tunnel & a wildcard subdomain, except that instead of http://localhost:80 I used http://coolify-proxy:80 (my CF tunnel public endpoint), because that's the only way it's working, as I found here

Then, in Coolify I created a new resource

services:
  cloudflared:
    container_name: cloudflare-tunnel
    image: 'cloudflare/cloudflared:latest'
    restart: unless-stopped
    command: 'tunnel --no-autoupdate run'
    environment:
      - 'TUNNEL_TOKEN=${CLOUDFLARE_TUNNEL_TOKEN}'
    networks:
      - coolify
networks:
  coolify:
    external: true

Then, on my CloudFlare domain -> SSL/TLS -> I've set the encryption mode to Full; I also tried with Full (strict)

Then, for each resource created, if I set a domain like http://test.mydomain.com, it works, except that for the https version http://test.mydomain.com I get This site can’t be reached.

Why isn't the https working?

PS: if I add the https from coolify settings for each resource, both version won't be reached.

2 Answers 2

5

Full answer:

  1. Create a tunnel with a name of your choice enter image description here
  2. Copy that command sudo cloudfalred..... paste this somewhere safe because this command will have the cloudflare tunnel token which we will need later enter image description here
  3. Enter the following details for hostname stuffs enter image description here
  4. Then copy your tunnel id enter image description here
  5. Create a new DNS record

Type - CNAME Name - * Target - .cfargotunnel.com enter image description here 6.Go to your coolify dashboard and create a new resource with the option dockercompose empty, and enter the following on the compose:

services:
  cloudflared:
    container_name: cloudflare-tunnel
    image: 'cloudflare/cloudflared:latest'
    restart: unless-stopped
    command: 'tunnel --no-autoupdate run'
    environment:
      - 'TUNNEL_TOKEN=${CLOUDFLARE_TUNNEL_TOKEN}'
    networks:
      - coolify
networks:
  coolify:
    external: true
  1. Add your cf tunnel token as env and then click the deploy button enter image description here
  2. Go your coolify settings, on instance domain enter a domain you want to access coolify UI, for my case I enter http://dev.shadowarcanist.com It is important to enter the domain as HTTP because if you put HTTPS here then you will get too many redirects error. enter image description here
  3. Go to the severs page on coolify dashboard and start the proxy if it is not running already enter image description here you don't have to change anything on the proxy page, the default settings works fine Now visit the domain you entered for coolify (on settings > instance domain) - Visiting the domain should show you the coolify login page on HTTPS
  4. If you can acces the coolify dashboard on HTTPS then you can access your website over HTTPS. On the resource settings you should enter the domain as HTTP not HTTPS (cloudflare will serve it over HTTPS) enter image description here
  5. (Optional) Set always use HTTPs in cloudflare enter image description here
Sign up to request clarification or add additional context in comments.

1 Comment

Do you know where does the "too many redirects" error originate from? Is it the Traefik proxy?
1

Update: it worked actually, but for some reason my Brave browser, even if I used incognito, cached the 'can't be reached' response forever. It worked using other browser :)

Full solution here - https://discord.com/channels/459365938081431553/1316486632714539061

2 Comments

The Link doesn't seem to work anymore. Could you share the solution here?
just added the full answer @leon

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.