k8s vue nginx css chorm无效 (Firefox正常)

chrom version
版本 83.0.4103.116(正式版本) (64 位)

解决方式:删除 dist/index.html 中的

nginx.conf

worker_processes auto;

events {
    worker_connections  1024;
}


http {
    
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        root   /usr/share/nginx/html;

        location / {
           # root   /usr/share/nginx/html;
           # index  index.html index.htm;
           try_files $uri $uri/ /index.html;
	}

	location /prod-api {
             proxy_pass http://burrow-api:3000;
        }

        location /api/v1 {
             proxy_pass http://burrow-api:3000;
        }

        location /ws {
             proxy_pass http://burrow-api:3000;
             proxy_http_version 1.1;
             proxy_set_header Host $host;
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_read_timeout 120s;

             proxy_set_header Upgrade websocket;
             proxy_set_header Connection Upgrade;
         }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    }
}

1、本地npm run build生成dist
2、制作dockerfile镜像

FROM nginx:latest

MAINTAINER [email protected]

WORKDIR /usr/src/app

COPY dist/  /usr/share/nginx/html/

COPY nginx.conf /etc/nginx/nginx.conf

EXPOSE 9528

RUN echo 'ok!!!'

2、新建Deployments
k8s vue nginx css chorm无效 (Firefox正常)_第1张图片

你可能感兴趣的:(nginx,nginx)