3

Installed Directus using docker-compose as outlined here along with NGINX as proxy

File docker-compose.yaml

version: "3"

networks:
  directus:

services:
  mysql:
    image: mysql:5.7
    environment:
      MYSQL_DATABASE: "directus"
      MYSQL_USER: "directus"
      MYSQL_PASSWORD: "directus"
      MYSQL_ROOT_PASSWORD: "directus"
    ports:
      - "3306:3306"
    networks:
      - directus

  directus:
    image: directus/directus:v8-apache
    ports:
      - "9090:80"
    container_name: directus
    environment:
      DIRECTUS_APP_ENV: "production"
      DIRECTUS_AUTH_PUBLICKEY: "some random secret"
      DIRECTUS_AUTH_SECRETKEY: "another random secret"
      DIRECTUS_DATABASE_HOST: "mysql"
      DIRECTUS_DATABASE_PORT: "3306"
      DIRECTUS_DATABASE_NAME: "directus"
      DIRECTUS_DATABASE_USERNAME: "directus"
      DIRECTUS_DATABASE_PASSWORD: "directus"
    volumes:
      - ./data/config:/var/directus/config
      - ./data/uploads:/var/directus/public/uploads    
    networks:
      - directus

  nginx:
    image: nginx
    depends_on:
      - directus
    container_name: nginx    
    volumes:
      - ./data/ntemplates:/etc/nginx/templates
      - ./directus.conf:/etc/nginx/conf.d/default.conf
    ports:
      - "8080:80"
    networks:
      - directus

NGINX conf file

File directus.conf

server {
    #/etc/nginx/conf.d/directus.conf 
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    location / {
       proxy_pass "http://directus:9090/"; 
    }
}

while http://localhost:9090 work properly, when try the same via http://localhost:8080 results into HTTP 5xx internal server error

nginx reports

[error] 2#2: *6 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 172.26.0.1, server: localhost:9090, request: "GET /favicon.ico HTTP/1.1", host:"localhost:8080", referrer: "http://localhost:8080/"

Vic
  • 1,985
  • 1
  • 19
  • 30

1 Answers1

2

I've launched the stack using your compose file and it went almost well. Unfortunately there was no redirect problem but nginx returned 502 because of incorrect port:

    location / {
       proxy_pass "http://directus:9090/"; 
    }

The 9090 port is on your host machine, not in the container. You have to change that for 80 or remove completely.

As for redirect problem, the source of it lays outside of what you have provided so far. My best guess is that it is somewhere in ./data/ntemplates. If there are files with .template extension, a script in nginx container will make config files of them.

My second best guess is that it is somewhere in ./data/config because I didn't have those files.

Thanks for providing the compose file, it saved me a lot of time to prepare this answer.

anemyte
  • 17,618
  • 1
  • 24
  • 45
  • Removing the port number as pointed out helped resolve the issue. I have not tested things in detail yet but seem to help get the UI working. Thanks – Vic Nov 06 '20 at 23:03