为基本HTTP配置Traefik,以便仪表板使用端口80-获取页面404找不到
我的VPS是Ubuntu 22.04 LTS无头,
我正在以/home/ubuntu
进行此操作,因此我有一个ubuntu
用户是Sudoer。
已经安装了Docker并运行Docker 版本20.10.15,Build FD82621
我的目的是 http oft http http first first 成功地安装和运行traefik。这是为了朝着我的最终目标建立运行多个应用程序,每个应用程序使用>>> ameedemowebsite.com
在同一vps上
我的traefik配置,
是我在/home/ubuntu
的步骤
mkdir traefik
cd traefik
mkdir data
cd data
touch acme.json
chmod 600 acme.json
touch traefik.yml
这 是我的/home/ubuntu/traefik/docker-compose.yml
version: '3.9'
services:
traefik:
image: traefik:v2.6
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
ports:
- 80:80
- 443:443
- 8080:8080
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /home/ubuntu/traefik/data/traefik.yml:/traefik.yml:ro
- /home/ubuntu/traefik/data/acme.json:/acme.json
- /home/ubuntu/traefik/data/config.yml:/config.yml:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(traefik.mydomaincom)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=USER:BASIC_AUTH_PASSWORD"
- "traefik.http.routers.traefik.service=api@internal"
networks:
proxy:
external: true
这是我的/home/home/ubuntu/traefik/traefik/data/traefik.yml
api:
dashboard: true
debug: true
insecure: true
entryPoints:
http:
address: ":80"
https:
address: ":443"
serversTransport:
insecureSkipVerify: true
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
file:
filename: /config.yml
log:
filePath: "/var/log/traefik.log"
format: json
level: DEBUG
dns设置
,我正在使用Cloudflare for Cloudflare。我的DNS
我的CF配置someDemowebsite.com
是
- ssl/tls加密模式(不安全)
- SSL/TLS推荐人是的是,
- 始终
/
在/home/home/ubuntu/ubuntu/traefik 我
docker network create proxy
docker compose up --force-recreate
看到
[+] Running 1/0
⠿ Container traefik Created 0.1s
Attaching to traefik
traefik | time="2022-05-13T14:31:12Z" level=info msg="Configuration loaded from file: /traefik.yml"
了我看到的东西
,我在http://traefik.somedemowebsite.com
我期望
提示用户名的基本auth和密码
更新
我可以使用端口8080时可以到达仪表板。但不能端口80。
如何分辨出哪个原因是因为这个404
我发现此 https://doc.traefik.io/traefik/getting-started/faq/faq/#404-not-found
有4个原因。我如何以某种方式进行调试,我可以知道造成404的原因是什么?
我引用
- 到达没有路由器的入口点的请求
- HTTP请求到达没有HTTP路由器的入口点
- HTTPS请求到达没有HTTPS路由器的入口点
- 到达具有无法匹配的HTTP/HTTPS路由器的入口点的请求
入口点,该请求 3因为我明确使用HTTP。
我该如何确定是1、2还是4?
My VPS is a ubuntu 22.04 LTS headless
I am doing this at /home/ubuntu
so I have a ubuntu
user that's a sudoer.
Already installed docker and running Docker version 20.10.15, build fd82621
My purpose is to install and run traefik successfully with just plain http first. It's to build towards my ultimate goal of running multiple apps each using a subdomain under somedemowebsite.com
on the same VPS
My Traefik Configuration
These are my steps at /home/ubuntu
mkdir traefik
cd traefik
mkdir data
cd data
touch acme.json
chmod 600 acme.json
touch traefik.yml
This is my /home/ubuntu/traefik/docker-compose.yml
version: '3.9'
services:
traefik:
image: traefik:v2.6
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
ports:
- 80:80
- 443:443
- 8080:8080
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /home/ubuntu/traefik/data/traefik.yml:/traefik.yml:ro
- /home/ubuntu/traefik/data/acme.json:/acme.json
- /home/ubuntu/traefik/data/config.yml:/config.yml:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(traefik.mydomaincom)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=USER:BASIC_AUTH_PASSWORD"
- "traefik.http.routers.traefik.service=api@internal"
networks:
proxy:
external: true
This is my /home/ubuntu/traefik/data/traefik.yml
api:
dashboard: true
debug: true
insecure: true
entryPoints:
http:
address: ":80"
https:
address: ":443"
serversTransport:
insecureSkipVerify: true
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
file:
filename: /config.yml
log:
filePath: "/var/log/traefik.log"
format: json
level: DEBUG
DNS settings
I am using CloudFlare for my DNS
My CF configurations for somedemowebsite.com
is
- SSL/TLS encryption mode is Off (not secure)
- SSL/TLS Recommender Yes
- Always Use HTTPS No
Commands
At /home/ubuntu/traefik
I did
docker network create proxy
docker compose up --force-recreate
I get a
[+] Running 1/0
⠿ Container traefik Created 0.1s
Attaching to traefik
traefik | time="2022-05-13T14:31:12Z" level=info msg="Configuration loaded from file: /traefik.yml"
What I saw
I get a page 404 not found error when I went to http://traefik.somedemowebsite.com
What i expected
to get prompted for basic auth for username and password
Update
I can reach the dashboard when I use port 8080. but not port 80.
how to tell which reason cause this 404
I found this https://doc.traefik.io/traefik/getting-started/faq/#404-not-found
there are 4 reasons. How do I debug in a way I can know which reason caused my 404?
I cite
- A request reaching an EntryPoint that has no Routers
- An HTTP request reaching an EntryPoint that has no HTTP Router
- An HTTPS request reaching an EntryPoint that has no HTTPS Router
- A request reaching an EntryPoint that has HTTP/HTTPS Routers that cannot be matched
I assume it's not 3 since I am explicitly only using http.
How do I tell whether it's 1, 2, or 4?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系,我已经解决了它。
主要的罪魁祸首是该域没有包裹在tick中。同样,要使基本验证工作能够工作,我需要将中间件分配给路由器。
评论是更改使事情起作用的地方。因此,对于
docker-compose.yml
Never mind I have solved it.
The main culprit is that the domain is not wrapped in ticks. Also for the basic auth to work i need to assign the middleware to the router.
Comments are where the changes made things work. So for
docker-compose.yml