我在虚拟主机上有一个域,在 Digital Ocean 上有一个子域。我正在尝试使用 traefik.toml 中的 acme 配置来注册 LetsEncrypt SSL 证书。
[acme]
email = "myemail@pirion.net"
storage = "acme.json"
entryPoint = "https"
OnHostRule = true
Run Code Online (Sandbox Code Playgroud)
日志提供以下错误:
time="2018-01-12T03:25:37Z" level=debug msg="LoadCertificateForDomains [endpoint.pirion.net]..."
time="2018-01-12T03:25:37Z" level=debug msg="Look for provided certificate to validate [endpoint.pirion.net]..."
time="2018-01-12T03:25:37Z" level=debug msg="No provided certificate found for domains [endpoint.pirion.net], get ACME certificate."
time="2018-01-12T03:25:37Z" level=debug msg="Loading ACME certificates [endpoint.pirion.net]..."
time="2018-01-12T03:25:37Z" level=error msg="map[endpoint.pirion.net:[endpoint.pirion.net] acme: Could not determine solvers]"
time="2018-01-12T03:25:37Z" level=error msg="Error getting ACME certificates [endpoint.pirion.net] : Cannot obtain certificates map[endpoint.pirion.net:[endpoint.pirion.net] acme: Could not determine …Run Code Online (Sandbox Code Playgroud) 我正在使用 traefik 和 docker 在我的服务器上运行多个服务。如果(子)域没有匹配的容器,如何指定默认或后备容器?例如,我的网站使用 example.com,nextcloud 使用 cloud.example.com。但是,当有人使用 www.example.com 或 wiki.example(或其他可能的子域之一)时,它应该重定向到我的网站,并且不显示 404 错误页面。
每个容器都有以下标签:
- traefik.port=<port>
- traefik.frontend.rule=Host:<sub-1>.example.com,<sub-2>.example.com
- traefik.frontend.entryPoints=http,https
Run Code Online (Sandbox Code Playgroud)
traefik 配置在这里(我使用的是traefik:1.6-alpine图像):
# General
logLevel = "INFO"
# EntryPoints
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
# Let's Encrypt
[acme]
entryPoint = "https"
email = "info@example.com"
storage = "/etc/traefik/acme/acme.json"
onHostRule = true
[acme.httpChallenge]
entryPoint = "http"
[[acme.domains]]
main = "example.com"
# Docker
[docker]
domain = "localhost"
watch = true
Run Code Online (Sandbox Code Playgroud) 我提前为我对 Traefik 的新手理解道歉,但是有没有办法使用基于请求的变量重写“非 www”域?
我已经在谷歌上搜索了一个多小时,找不到答案。
这是我将如何在 Apache 中执行此操作的示例。您可以看到它正在使用HTTP_HOST变量:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)
我可以看到我可以像这样设置标签:
--label "traefik.frontend.redirect.permanent=true"
--label "traefik.frontend.redirect.regex=^https?://www.example.com/(.*)"
--label "traefik.frontend.redirect.replacement=https://example.com/${1}"
Run Code Online (Sandbox Code Playgroud)
但这需要我example.com为一切做好准备。我希望无论域如何都可以重定向。谢谢!
我希望在docker-compose up我的 wordpress 堆栈中看到一个新的前端和后端。
没有新的前端或后端。2 日志行 =level=info msg="Skipping same configuration for provider docker"
也看到"Filtering disabled container /testEXAMPLEcom_wordpress_1"即使traefik.enable=true设置在标签中。
traefik version:Traefik version v1.7.11 built on 2019-04-26_08:42:33AM
Run Code Online (Sandbox Code Playgroud)
cat traefik.toml
#debug = true
logLevel = "INFO" #DEBUG, INFO, WARN, ERROR, FATAL, PANIC
InsecureSkipVerify = true
defaultEntryPoints = ["https", "http"]
# WEB interface of Traefik - it will show web page with overview of frontend and backend configurations
[api]
entryPoint = "traefik" …Run Code Online (Sandbox Code Playgroud) 这是我几天来一直在解决的问题,但我找不到有关 stackoverflow 的任何帮助,甚至没有找到任何帮助。我希望能帮助将来有类似问题的人。非常欢迎对此问题/答案的任何详细说明。
在Docker环境中使用Traefik作为代理时,我一直试图将STS-headers设置为 http-requests 。不知何故,无论我如何尝试设置标题,我的浏览器(谷歌浏览器)都会忽略它们。我究竟做错了什么?
我正在尝试在 docker swarm 模式下使用 traefik 2.0 (!)。这是我的堆栈:
version: '3.7'
services:
traefik:
image: traefik:latest
ports:
- 80:80
- 443:443
deploy:
replicas: 1
placement:
constraints:
- node.role == manager
preferences:
- spread: node.id
labels:
- traefik.enable=true
- traefik.http.routers.traefikRouter.rule=Host(`127.0.0.11`)
- traefik.http.routers.traefikRouter.service=api@internal
- traefik.http.routers.traefikRouter.entrypoints=http
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: >
--providers.docker
--providers.docker.exposedbydefault=false
--providers.docker.swarmmode=true
--entryPoints.http.address=":80"
--entryPoints.https.address=":443"
--accesslog
--log.level=DEBUG
--api=true
--api.dashboard=true
networks:
- traefik-public
whoami:
image: containous/whoami
deploy:
replicas: 2
labels:
- traefik.enable=true
- traefik.http.services.whoami.loadbalancer.server.port=80
- traefik.http.routers.whoami.rule=Host(`127.0.0.12`)
- traefik.http.routers.whoami.service=whoami
- traefik.http.routers.whoami.entrypoints=http
networks:
- traefik-public
# Run on …Run Code Online (Sandbox Code Playgroud) 我设置了一个监听 4000 端口的 GraphQL 游乐场。
所以我添加了以下 Traefik 标签:
graphql:
restart: unless-stopped
labels:
- traefik.enable=true
- "traefik.http.routers.${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG}-graphql.rule=Host(`graphql.${CI_ENVIRONMENT_HOST}`)"
- traefik.http.routers.${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG}-graphql.tls.certresolver=letsencrypt
- traefik.http.services.${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG}-graphql.loadbalancer.server.port=4000
Run Code Online (Sandbox Code Playgroud)
当我尝试获取graphql.site.com.
现在我希望它匹配site.com/graphql,所以我将路由器标签更改为:
"traefik.http.routers.${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG}-graphql.rule=Host(`${CI_ENVIRONMENT_HOST}`) && Path(`/graphql`)"
Run Code Online (Sandbox Code Playgroud)
使用此配置,我在site.com/graphql.
我错过了什么?
我正在尝试在traefik.yml文件中声明 https 重定向。现在我尝试在.traefik服务中添加这些规则docker-compose.yml。这就像一个魅力。虽然我更喜欢在traefik.yml文件中配置这个全局和中间件重定向,然后只在 .traefik 服务中引用它docker-compose.yml。
version: '3'
networks:
web:
external: true
services:
traefik:
image: traefik:v2.1
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./.traefik/traefik.yml:/traefik.yml
- ./.traefik/acme.json:/acme.json
networks:
- web
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`$HOSTNAME`)"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.tls.certresolver=le"
- "traefik.http.routers.traefik.entrypoints=https"
# Global redirect to https
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.entrypoints=http"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
# Middleware redirect
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
Run Code Online (Sandbox Code Playgroud)
这很容易,并将所有其他域从 http 重定向到 https。
我想在traefik.yml.
到目前为止,我已经这样做了。
api: {}
entryPoints: …Run Code Online (Sandbox Code Playgroud) 这可能是一个关于 traefik 和 SSL 配置的新手问题。我想在 traefik 中使用我自己的(自签名,公司,...)证书。我试图遵循文档,但我不断收到以下消息:
... level=debug msg="没有默认证书,生成一个"
我的traefik.toml看起来像这样:
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.web.http]
[entryPoints.web.http.redirections]
[entryPoints.web.http.redirections.entryPoint]
to = "websecure"
scheme = "https"
[entryPoints.websecure]
address = ":443"
[log]
level = "DEBUG"
[api]
insecure = true
dashboard = true
[providers.docker]
exposedByDefault = false
[[tls]]
entryPoints = ["websecure"]
[[tls.certificate]]
certFile = "/certs/cert.crt"
keyFile = "/certs/cert.key"
[tls.stores]
[tls.stores.default]
[tls.stores.default.defaultCertificate]
certFile = "/cert/cert.crt"
keyFile = "/cert/cert.key"
Run Code Online (Sandbox Code Playgroud)
我的docker-compose.yml样子是这样的:
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.web.http]
[entryPoints.web.http.redirections]
[entryPoints.web.http.redirections.entryPoint]
to = "websecure" …Run Code Online (Sandbox Code Playgroud) 我正在学习 helm3 和 k8s (microk8s)。在尝试以下命令时:
helm install traefik traefik/traefik -n traefik --values traefik-values.yaml
Run Code Online (Sandbox Code Playgroud)
和 traefik-values.yaml 具有以下值:
additionalArguments:
- "--certificatesresolvers.letsencrypt.acme.email=<my-email>"
- "--certificatesresolvers.letsencrypt.acme.storage=/data/acme.json"
- "--certificatesresolvers.letsencrypt.acme.caserver=https://acme-v02.api.letsencrypt.org/directory"
- "--certificatesResolvers.letsencrypt.acme.tlschallenge=true"
- "--api.insecure=true"
- "--accesslog=true"
- "--log.level=INFO"
hostNetwork: true
ipaddress: <my-ip>
service:
type: ClusterIP
ports:
web:
port: 80
websecure:
port: 443
Run Code Online (Sandbox Code Playgroud)
我收到此绑定权限错误
traefik.go:76: command traefik error: error while building entryPoint web: error preparing server: error opening listener: listen tcp :80: bind: permission denied
Run Code Online (Sandbox Code Playgroud)
另一方面,我可以使用以下yaml文件(大约是Traefik 站点上的示例)在相同的端口(80 和 443)上安装 Traefik :
---
apiVersion: v1 …Run Code Online (Sandbox Code Playgroud)