简体   繁体   English

将 Traefik 反向代理到 Docker 容器中的 Nginx

[英]Reverse proxy Traefik to Nginx in Docker containers

This is necessary as Traefik doesn't support php-fpm.这是必要的,因为 Traefik 不支持 php-fpm。

This docker-compose.yml doesn't work:这个 docker-compose.yml 不起作用:

version: '3'
services:

  #php
  ...
  
  #Nginx Service
  webserver:
    image: nginx:alpine
    container_name: webserver
    restart: unless-stopped
    tty: true
    volumes:
      - ./:/var/www
      - ./nginx/conf.d/:/etc/nginx/conf.d/
    networks:
      - app-network
      - traefik
    labels:
      - traefik.http.routers.webserver.rule=Host(`nginx.your_domain`)
      - traefik.http.routers.webserver.tls=true
      - traefik.http.routers.webserver.tls.certresolver=lets-encrypt
      - traefik.port=80

#Docker Networks
networks:
  app-network:
    driver: bridge
  traefik:
    external: true

However, if I make an innocuous edit like change the version number to 3.7 (or change back to 3 , from 3.7 ) it suddenly works, but isn't consistent.但是,如果我进行无害的编辑,例如将版本号更改为3.7 (或从3.7更改回3 ),它会突然起作用,但不一致。

How do I successfully route Traefik to an Nginx container?如何成功地将 Traefik 路由到 Nginx 容器?

#1. #1。 Docker compose file version is related to the engine, so please make sure you match that: Docker 撰写文件版本与引擎有关,因此请确保您匹配:

https://docs.docker.com/compose/compose-file/ https://docs.docker.com/compose/compose-file/

#2. #2。 You could try to run the basic example from Traefik:您可以尝试从 Traefik 运行基本示例:

https://doc.traefik.io/traefik/user-guides/docker-compose/basic-example/ I'm assuming this is traefik latest (2.4) https://doc.traefik.io/traefik/user-guides/docker-compose/basic-example/我假设这是最新的 traefik (2.4)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM