title: 404 Error When Using Traefik With Nginx
body: <p>My setup is over Rancher/Docker, and I'm trying to get my InvoiceNinja stack online through the use of Traefik.</p>
  
  <p>I currently have the two other containers that I've been able to make public, but haven't had to try and connect through a nginx container before.</p>
  
  <p>When accessing <a href="https://invoiceninja.example.com" rel="nofollow noreferrer">https://invoiceninja.example.com</a>, I simply get 404 error. I can access it locally just using the IP and port of the host &amp; container just fine.</p>
  
  <p><strong>docker-compose.yml:</strong></p>
  
  <pre><code>version: '2'
  services:
    app:
      image: invoiceninja/invoiceninja:latest
      dns:
        - 1.1.1.1
        - 1.0.0.1
      environment:
        APP_ENV: production
        APP_DEBUG: false
        APP_URL: https://${TRAEFIK_HOST}
        APP_CIPHER: AES-256-CBC
        APP_KEY: ${APP_KEY}
        DB_STRICT: false
        DB_HOST: mysql
        DB_DATABASE: ninja_db
        DB_USERNAME: ninja
        DB_PASSWORD: ${DB_USER_PASS}
        {{- if (.Values.MOBILE_APP_SECRET)}}
        API_SECRET: ${MOBILE_APP_SECRET}
        {{- end}}
        {{- if (.Values.GMAPS_KEY)}}
        GOOGLE_MAPS_API_KEY: ${GMAPS_KEY}
        {{- end}}
      labels:
        io.rancher.container.pull_image: always
        {{- if (.Values.HOST_LABEL)}}
        io.rancher.scheduler.affinity:host_label: ${HOST_LABEL}
        {{- end}}
        io.rancher.sidekicks: cron, web
      links:
        - mysql
      restart: on-failure
      volumes:
        - Logo:/var/www/app/public/logo
        - Storage:/var/www/app/storage
    cron:
      image: invoiceninja/invoiceninja:latest
      dns:
        - 1.1.1.1
        - 1.0.0.1
      entrypoint: |
        bash -c 'bash -s &lt;&lt;EOF
        trap "break;exit" SIGHUP SIGINT SIGTERM
        sleep 300s
        while /bin/true; do
          ./artisan ninja:send-invoices
          ./artisan ninja:send-reminders
          sleep 1h
        done
        EOF'
      environment:
        APP_ENV: production
        APP_DEBUG: false
        APP_URL: https://${TRAEFIK_HOST}
        APP_CIPHER: AES-256-CBC
        APP_KEY: ${APP_KEY}
        DB_STRICT: false
        DB_HOST: mysql
        DB_DATABASE: ninja_db
        DB_USERNAME: ninja
        DB_PASSWORD: ${DB_USER_PASS}
        {{- if .Values.MOBILE_APP_SECRET}}
        API_SECRET: ${MOBILE_APP_SECRET}
        {{- end}}
        {{- if .Values.GMAPS_KEY}}
        GOOGLE_MAPS_API_KEY: ${GMAPS_KEY}
        {{- end}}
      labels:
        io.rancher.container.pull_image: always
        {{- if .Values.HOST_LABEL}}
        io.rancher.scheduler.affinity:host_label: ${HOST_LABEL}
        {{- end}}
      links:
        - mysql
      restart: on-failure
      volumes_from:
        - app
    mysql:
      image: mysql:5
      dns:
        - 1.1.1.1
        - 1.0.0.1
      environment:
        MYSQL_DATABASE: ninja_db
        MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASS}
        MYSQL_USER: ninja
        MYSQL_PASSWORD: ${DB_USER_PASS}
      labels:
        io.rancher.container.pull_image: always
        {{- if .Values.HOST_LABEL}}
        io.rancher.scheduler.affinity:host_label: ${HOST_LABEL}
        {{- end}}
      restart: on-failure
      volumes:
        - Database:/var/lib/mysql
    web:
      image: nginx
      dns:
        - 1.1.1.1
        - 1.0.0.1
      labels:
        io.rancher.container.pull_image: always
        {{- if .Values.HOST_LABEL}}
        io.rancher.scheduler.affinity:host_label: ${HOST_LABEL}
        {{- end}}
        {{- if .Values.TRAEFIK_HOST}}
        traefik.enable: true
        traefik.frontend.rule: Host:${TRAEFIK_HOST}
        traefik.port: "80"
        traefik.frontend.entryPoints: https
        traefik.frontend.passHostHeader: true
        {{- else}}
        traefik.enable: false
        {{- end}}
      links:
        - app
      networks:
        - public-proxy
      ports:
        - "${WEB_PORT}:80"
      restart: on-failure
      volumes:
        - /RancherConfig/${DATA_DIR}/nginx.conf:/etc/nginx/nginx.conf:ro
      volumes_from:
        - app
  networks:
    public-proxy:
      external: true
  </code></pre>
  
  <p><strong>nginx.conf:</strong></p>
  
  <pre><code>user www-data;
  
  events {
    worker_connections 768;
  }
  
  http {
      upstream backend {
          server app:9000;
      }
      include /etc/nginx/mime.types;
      default_type application/octet-stream;
      gzip on;
      gzip_disable "msie6";
  
      server {
          listen      80 default;
          server_name invoiceninja.example.com;
  
          root /var/www/app/public;
  
          index index.php;
  
          charset utf-8;
  
          location / {
              try_files $uri $uri/ /index.php?$query_string;
          }
  
          location = /favicon.ico { access_log off; log_not_found off; }
          location = /robots.txt  { access_log off; log_not_found off; }
  
          sendfile off;
  
          location ~ \.php$ {
              fastcgi_split_path_info ^(.+\.php)(/.+)$;
              fastcgi_pass backend;
              fastcgi_index index.php;
              include fastcgi_params;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
              fastcgi_intercept_errors off;
              fastcgi_buffer_size 16k;
              fastcgi_buffers 4 16k;
          }
  
          location ~ /\.ht {
              deny all;
          }
      }
  }
  </code></pre>
  
  <p>I tried (and still have) using the "traefik.frontend.passHostHeader: true" label as a similar issue, but does not seem to make a difference.</p>
  
  <p>Any help is greatly appreciated!
  Thank you!</p>