title: Using NGINX as reverse proxy for running Directus via using docker-compose results into rewrite or internal redirection cycle
body: <p>Installed Directus using docker-compose as outlined <a href="https://docs.directus.io/installation/docker.html" rel="nofollow noreferrer">here</a> along with NGINX as proxy</p>
  <blockquote>
  <p>File <strong>docker-compose.yaml</strong></p>
  </blockquote>
  <pre><code>version: &quot;3&quot;
  
  networks:
    directus:
  
  services:
    mysql:
      image: mysql:5.7
      environment:
        MYSQL_DATABASE: &quot;directus&quot;
        MYSQL_USER: &quot;directus&quot;
        MYSQL_PASSWORD: &quot;directus&quot;
        MYSQL_ROOT_PASSWORD: &quot;directus&quot;
      ports:
        - &quot;3306:3306&quot;
      networks:
        - directus
  
    directus:
      image: directus/directus:v8-apache
      ports:
        - &quot;9090:80&quot;
      container_name: directus
      environment:
        DIRECTUS_APP_ENV: &quot;production&quot;
        DIRECTUS_AUTH_PUBLICKEY: &quot;some random secret&quot;
        DIRECTUS_AUTH_SECRETKEY: &quot;another random secret&quot;
        DIRECTUS_DATABASE_HOST: &quot;mysql&quot;
        DIRECTUS_DATABASE_PORT: &quot;3306&quot;
        DIRECTUS_DATABASE_NAME: &quot;directus&quot;
        DIRECTUS_DATABASE_USERNAME: &quot;directus&quot;
        DIRECTUS_DATABASE_PASSWORD: &quot;directus&quot;
      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:
        - &quot;8080:80&quot;
      networks:
        - directus
  
  </code></pre>
  <p>NGINX conf file</p>
  <blockquote>
  <p>File <strong>directus.conf</strong></p>
  </blockquote>
  <pre><code>server {
      #/etc/nginx/conf.d/directus.conf 
      listen       80;
      listen  [::]:80;
      server_name  localhost;
  
      location / {
         proxy_pass &quot;http://directus:9090/&quot;; 
      }
  }
  
  </code></pre>
  <p>while http://localhost:9090 work properly, when try the same via http://localhost:8080 results into HTTP 5xx internal server error</p>
  <p>nginx reports</p>
  <blockquote>
  <p>[error] 2#2: *6 rewrite or internal redirection cycle while internally redirecting to &quot;/index.php&quot;, client: 172.26.0.1, server: localhost:9090, request: &quot;GET /favicon.ico HTTP/1.1&quot;, host:&quot;localhost:8080&quot;, referrer: &quot;http://localhost:8080/&quot;</p>
  </blockquote>