Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
373 views
in Technique[技术] by (71.8m points)

Port problem using docker-compose and traefik

i am trying to do a staging machine with the following set:

-docker-compose:

version: "3"

services:
 

  drupal:
    build: .
    container_name: drupal
    labels:
      - traefik.enable=false
    restart: unless-stopped

    volumes:
      - ../main:/var/www/html
      - ./settings/settings.php:/var/www/html/web/sites/default/settings.php

  webserver:
    image: nginx:1.17.4-alpine
    container_name: webserver
    depends_on:
      - drupal
    restart: unless-stopped
    labels:
      - traefik.docker.network=web
      - traefik.http.routers.blog.rule=Host(`drupal-nginx-traefick.staging.oto.agency`)
      - traefik.http.routers.blog.tls=true
      - traefik.http.routers.blog.tls.certresolver=lets-encrypt
      - traefik.port=80
    volumes:
      - ../main:/var/www/html
      - ./settings/nginx-conf:/etc/nginx/conf.d

and nginx conf:

server {
    listen 80;
    listen [::]:80;

    server_name drupal-nginx-traefick.staging.oto.agency;

    location ~ /.well-known/acme-challenge {
        allow all;
        root /var/www/html;
    }

    location / {
        rewrite ^ https://$host$request_uri? permanent;
    }
}
server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name drupal-nginx-traefick.staging.oto.agency;

    index index.php index.html index.htm;

    root /var/www/html/web;

    server_tokens off;

    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header Referrer-Policy "no-referrer-when-downgrade" always;
    add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    rewrite ^/core/authorize.php/core/authorize.php(.*)$ /core/authorize.php$1;

    location ~ .php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass drupal:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location ~ /.ht {
        deny all;
    }

    location = /favicon.ico {
        log_not_found off; access_log off;
    }
    location = /robots.txt {
        log_not_found off; access_log off; allow all;
    }
    location ~* .(css|gif|ico|jpeg|jpg|js|png)$ {
        expires max;
        log_not_found off;
    }
}

but when i start i get the following error:

webserver    | 2021/02/04 11:41:35 [emerg] 1#1: host not found in upstream "drupal" in /et
c/nginx/conf.d/nginx.conf:42
webserver    | nginx: [emerg] host not found in upstream "drupal" in /etc/nginx/conf.d/ngi
nx.conf:42

anyone can help me with this problem? i think it is a problem port or maybe idk the webserver container can't see the other, i have tried to set drupal ports 9000 but don't work

question from:https://stackoverflow.com/questions/66046012/port-problem-using-docker-compose-and-traefik

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...