<p>This is my deployment for the django app with rest framework:</p>

<pre><code>#Deployment
apiVersion: extensions/v1beta1
kind: Deployment
metadata: 
  labels: 
    service: my-api-service e
  name: my-api-deployment 

spec: 
  replicas: 1
  template: 
    metadata: 
      labels: 
        name: my-api-selector
    spec: 
      containers: 
        - 
          name: nginx
          image: nginx
          command: [nginx, -g,'daemon off;']
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - 
              name: shared-disk
              mountPath: /static
              readOnly: true
            - 
              name: nginx-config
              mountPath: /etc/nginx/nginx.conf
              subPath: nginx.conf

          ports:
            - 
              name: nginx
              containerPort: 80
        - 
          env: 

            - 
              name: STATIC_ROOT
              value: /src/static/
            -
              name: MEDIA_ROOT
              value: /src/media/         
            -
              name: CLIENT_ORIGIN
              value: https://marketforce.platinumcredit.co.ke
            -
              name: DJANGO_SETTINGS_MODULE
              value: config.production
            -
              name: DEBUG
              value: "true"

          image: localhost:5000/workforce-api:0.2.0         
          command: [ "./entrypoint.sh" ]
          name: my-api-container
          imagePullPolicy: IfNotPresent
          ports: 
            - 
              name: my-api-port
              containerPort: 9000
              protocol: TCP

          volumeMounts:
            - 
              name: shared-disk
              mountPath: /src/static


      initContainers:
        - 
          name: assets
          image: localhost:5000/workforce-api:0.2.0
          command: [bash, -c]
          args: ["python manage.py collectstatic --noinput"]
          command: [bash, -c]
          args: ["sleep 10"]
          command: [bash, -c]
          args: ["cp -r static/* /data"]
          imagePullPolicy: IfNotPresent
          volumeMounts:
            - 
              mountPath: /data
              name: shared-disk
      volumes:
        -
          name: shared-disk
          emptyDir: {}
        -
          name: nginx-config
          configMap:
            name: nginx-config
</code></pre>

<p>My service:</p>

<pre><code># Service
apiVersion: v1
kind: Service
metadata:
  name: my-api-service
  labels:
    label: my-api-service
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
    name: http

  selector:
    name: my-api-selector
</code></pre>

<p>And here's my nginx configuration: </p>

<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
data:
  nginx.conf: |
    events {
      worker_connections  1024;
    }
    http {
      upstream api {
        server 127.0.0.1:9000 fail_timeout=0;
      }
      server {
        access_log /var/log/nginx/api.my.log;
        error_log /var/log/nginx/api.my.mesozi.com-http-error.log;
        listen 80;
        server_name localhost;

        location /static/ {
          autoindex on;    
          alias /static/; 
        }

        location /media/ {
        alias   /src/media/;
        }

       location = /favicon.ico {
        access_log off;
        log_not_found off;
        }


        location / {
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $host;
          proxy_set_header X-NginX-Proxy true;
          proxy_pass http://127.0.0.1:9000/;
        }
      }
    }
</code></pre>

<p>As you can see in my deployment file I am running both nginx and my app in the same pod. Everything's running well in minikube except it's like the styles are not being applied. Looking at <code>network</code> in the browser all static file requests are OK <code>200</code>. What am I missing?</p>

<p>I guess displaying styles for my API is not any useful but I just want to get it tow work cause it should.</p>

<p>Looking at your static files section:</p>

<pre><code>location /static/ {
          autoindex on;    
          alias /static/; 
        }
</code></pre>

<p>Is  <code>/static/</code> an absolute path to your static web files?, if not, use the full path on alias since root has not been defined earlier.</p>

<p>Again why do you have autoindex flag turned on for this kind of files, it should be set to off like:</p>

<pre><code>autoindex off;
</code></pre>

<p>Alternatively you could try using the root definition for static files:</p>

<pre><code>location /static/ {
        root /var/;
        autoindex off;
      }
</code></pre>

<p>Then under <code>/var</code> have a static folder <code>/var/static</code>. The location part is appended to the path specified in the root.</p>
