如何在带有自定义路径的AWS ALB后面为Traefik v2.3提供Wordpress服务?

时间:2020-09-04 14:33:09

标签: docker traefik

我有一个Wordpress博客,我想在mydomain.com/blog上托管。我正在Docker上使用Traefik v2.3,其图像为wordpress:latest。

我有一个AWS ALB负载均衡器,该负载均衡器终止https:443上的证书,并将trafick发送到http:80。我不想终止Traefik中的tls证书。即使从配置中注释掉tls = true和resolver标签,我的traefik日志中仍然会出现错误。

level = error msg =“无法获得域的ACME证书 “ www.mydomain.com”:无法为域生成证书 [www.mydomain.com]:错误:一个或多个域有一个 问题:\ n [www.mydomain.com] acme:错误:403 :: urn:ietf:params:acme:error:unauthorized ::无法协商ALPN tls-alpn-01质询的协议“ acme-tls / 1”,网址:\ n” providerName = letsencryptresolver.acme routerName = rxblog-secure @ docker Rule =“ Host(www.mydomain.com)&& PathPrefix(/blog)”

在浏览器中,我收到“页面无法正确重定向”。

这是我的wordpress配置:

version: '3.8'

networks:
  traefik:
    external: true

volumes:
  data:

services:

  blog:
    image: wordpress:latest
    container_name: blog
    restart: always
    networks:
      - traefik
    environment:
      - WORDPRESS_DB_HOST=us-east-1.rds.amazonaws.com
      - WORDPRESS_DB_USER=wordpress
      - WORDPRESS_DB_PASSWORD=
      - WORDPRESS_DB_NAME=wordpress
    volumes:
      - type: volume
        source: data
        target: /var/www/html
      - type: bind
        source: ./uploads.ini
        target: /usr/local/etc/php/conf.d/uploads.ini
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.blog.entrypoints=web"
      - "traefik.http.routers.blog.rule=Host(`www.mydomain.com`) && PathPrefix(`/blog`)"
      - "traefik.http.routers.blog.middlewares=redirect-to-https@docker"
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
      - "traefik.http.routers.blog-secure.entrypoints=websecure"
      - "traefik.http.routers.blog-secure.rule=Host(`www.mydomain.com`) && PathPrefix(`/blog`)"
      - "traefik.http.services.blog-secure.loadbalancer.server.port=80"
      - "traefik.http.routers.blog-secure.tls=true"
      - "traefik.http.routers.blog-secure.tls.certresolver=letsencryptresolver"
      - "traefik.http.middlewares.blog-secure.stripprefix.prefixes=/blog"
      - "traefik.http.middlewares.blog-secure.stripprefix.forceslash=false"

我对标签进行了如下编辑:

- "traefik.enable=true"
- "traefik.http.routers.rxblog.entrypoints=web"
- "traefik.http.routers.wordpress.rule=Host(`www.mydomain.com`) && PathPrefix(`/`)"
- "traefik.http.services.rxblog.loadbalancer.server.port=80"
- "traefik.http.middlewares.rxblog.stripprefix.prefixes=/blogtest"
- "traefik.http.middlewares.rxblog.stripprefix.forceslash=false"

并且我添加了一个.htaccess文件,如下所示:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

我无法将以上各项组合使用。我刚得到404的/ blog /

1 个答案:

答案 0 :(得分:-1)

删除路由器上的tls设置。

- "traefik.http.routers.blog-secure.tls=true"
- "traefik.http.routers.blog-secure.tls.certresolver=letsencryptresolver"