I’m using traefik.
On my local machine, by using /etc/hosts, the traefik could handle subdomain very well, but with Cloudflare, it is not working.
Here is what happened when I visit http://whoami.ai-tools-online.xyz
local with hosts:
traefik | 172.19.0.1 - - [21/Feb/2023:01:35:46 +0000] "GET / HTTP/1.1" 200 722 "-" "-" 1 "[email protected] " "http://whoami:80" 13ms
remote with Cloudflare:
traefik | 172.70.222.109 - - [21/Feb/2023:01:31:53 +0000] "GET / HTTP/1.1" 404 19 "-" "-" 13 "-" "-" 3ms
Here are some details about this bug:
https://community.traefik.io/t/cloudflare-subdomain-a-records-not-working-with-traefik/17644
Chaika
February 21, 2023, 2:09am
3
I don’t know much about Traefik, but it since it’s responding, but just with a 404, it looks like you are doing some host header matching (or well, Traefik is).
Your config, you posted on the other site
rule: "Host(`whoami.weloveparty.domain.local`)"
Looks like it’s only matching if the host is your local one.
It looks like you might want something like this:
rule: "Host(`whoami.weloveparty.domain.local`) || Host(`whoami.ai-tools-online.xyz`)"
Or
rule: "Host(`whoami.weloveparty.domain.local`, `whoami.ai-tools-online.xyz`)"
Both should work, at least according to their docs.
Yes, thanks for the replying
But that’s exactly what I did
I have used this as the config, but it’s not working, that’s why I wrote this post:
http:
routers:
whoami_router:
entryPoints:
- web
- websecure
rule: "Host(`whoami.ai-tools-online.xyz`)"
service: whoami_service
services:
whoami_service:
loadBalancer:
servers:
- url: http://whoami:80
Chaika
February 21, 2023, 2:57am
5
I see. I don’t know enough about Traefik to help much more. The 404 you are getting is coming from your origin - Traefik, and this shouldn’t be Cloudflare specific, you could try disabling proxy on that record or pausing Cloudflare entirely, and the same behavior should be observed.
Unless someone else on this community forums knows Traefik and is able to help, your best bet might just be the other community forum.
Hello again, I’ve used nginx to do the same experiment, it’s still got problems, it can’t get subdomains
The nginx logs when I visit whoami.ai-tools-online.xyz
:
209.141.51.123 - - [24/Feb/2023:01:33:24 +0000] "GET / HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
209.141.51.123 - - [24/Feb/2023:01:33:25 +0000] "GET / HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
209.141.51.123 - - [24/Feb/2023:01:33:25 +0000] "GET / HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
209.141.51.123 - - [24/Feb/2023:01:33:26 +0000] "GET / HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
209.141.51.123 - - [24/Feb/2023:01:33:33 +0000] "GET / HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
209.141.51.123 - - [24/Feb/2023:01:33:37 +0000] "GET / HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
209.141.51.123 - - [24/Feb/2023:01:33:39 +0000] "GET / HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
Here is the Cloudflare config:
I found it got the following log only when the first visit in firefox’s incognito mode:
210.22.19.73 - - [24/Feb/2023:01:37:07 +0000] "GET /favicon.ico HTTP/1.1" 404 19 "http://whoami.ai-tools-online.xyz/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0"
58.251.73.232 - - [24/Feb/2023:01:38:25 +0000] "GET / HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0"
210.22.19.74 - - [24/Feb/2023:01:38:25 +0000] "GET / HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0"
58.251.73.232 - - [24/Feb/2023:01:38:30 +0000] "GET / HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0"
210.22.19.74 - - [24/Feb/2023:01:38:30 +0000] "GET / HTTP/1.1" 404 19 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/110.0"
I have used curl to make a visit:
curl -H 'Host: whoami.ai-tools-online.xyz' http://127.0.0.1:80
404 page not found
It seems like the nginx still couldn’t get the host information:
127.0.0.1 - - [24/Feb/2023:01:56:09 +0000] "GET / HTTP/1.1" 404 19 "-" "curl/7.85.0"
127.0.0.1 - - [24/Feb/2023:01:56:41 +0000] "GET / HTTP/1.1" 404 19 "-" "curl/7.85.0"
Finally, I solved this problem by delete duplicated traefik config files (traefik reads everything under a config folder no matter what “.xx” suffix that file has.
For example, my docker config is:
traefik:
image: "traefik:v3.0.0-beta2" #"traefik:v2.9.6"
container_name: "traefik"
command:
- "--accesslog=true"
# - "--accessLog.filePath=/tmp/traefik_log.txt"
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.file.directory=/traefik_dynamic_configs"
- "--providers.file.watch=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=true"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
ports:
- "80:80"
# - "443:443"
#- "8081:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./configs/traefik_dynamic_configs:/traefik_dynamic_configs" # <== Volume for dynamic conf file
restart: unless-stopped
Under the traefik_dynamic_configs
folder, should always have one single config file !!!
By the way, the traefik config could be:
```
rule: "Host(`whoami.ai-tools-online.xyz`) || Host(`whoami.weloveparty.domain.local`) || Path(`/hi`)"
```
— by yingshaoxo
system
Closed
March 11, 2023, 2:48am
13
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.