I have a multi stage docker image for my angular app which uses the nginx:alpine base image. I have the following nginx config and VHOST setup files(inside the docker container).
/etc/nginx/nginx.conf
/etc/nginx/conf.d/default.conf
My project files are under
/usr/share/nginx/html
Below are my configurations:
1. default.conf
server {
listen 0.0.0.0:80;
listen [::]:80;
default_type application/octet-stream;
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
client_max_body_size 256M;
root /usr/share/nginx/html;
location / {
try_files $uri $uri/ /index.html =404;
}
}
2. nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
As you can see, the mime.types file is already included and this file is present in the given path.
When i run this application, I get the following error in the browser(for the css and javascript files that are loaded):
Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
I tried many combinations suggested in the forums but no luck. Please let me know if you have a solution hint.
index.htmlwhich explains the MIME type in the error message.index.htmlfor non-existent files.