我正在练习PWA应用程序,并停留在我的第一个生产版本中。我正在使用通过docker + nginx部署的项目文件使用nginx配置工具。
我认为我的问题出在nginx配置中,因为在具有相同docker映像的本地环境中,一切工作都像灵符一样。
我的项目是vue-cli的默认模板,其中已激活/集成了pwa,vuex和路由器。
server {
server_name www.domain.de;
client_max_body_size 100M;
listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.domain.de/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.domain.de/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location index.html {
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
}
location service-worker.js {
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
}
location / {
gzip_static on;
proxy_pass http://127.0.0.1:8123$request_uri;
proxy_redirect off;
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_set_header X-Forwarded-Host $server_name;
}
}
我的项目的Dockerfile
FROM node:9.11.1-alpine as build-stage
WORKDIR /app
COPY package*.json ./
RUN npm config set unsafe-perm true
RUN npm install
COPY . .
RUN npm run build
FROM nginx:1.15.5-alpine as production-stage
COPY --from=build-stage /app/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
无法加载网站,并且控制台中出现空白页面,并显示以下错误消息
Chrome浏览器:
GET https://www.domain.de/js/chunk-vendors.0a3c4518.js net::ERR_SPDY_PROTOCOL_ERROR 200
Firefox:
Loading failed for the <script> with source “https://domain.de/js/chunk-vendors.0a3c4518.js”.