嘿,所以我用 Nginx 设置了 vue,它工作得很好,直到昨天我什么都没做,但是在尝试访问网站时我得到了这个,它不是生产系统,它是本地服务器上的测试系统
另外,我没有在容器 Maby 上获取 Portainer 的日志,它的重要性不知道。当我在我的系统上本地启动 docker 容器时,它没有问题
我的 Dockerfile
FROM node:13-alpine as evenman-frontend-build
ARG environment
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json
RUN npm install @vue/cli -g
RUN npm install --silent
RUN npm audit fix
COPY . /app
RUN npm run build -- --mode $environment
# production environment
FROM nginx:stable-alpine
COPY --from=evenman-frontend-build /app/dist /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Nginx 配置
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
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;
server {
listen 80 default_server;
listen [::]:80 default_server;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location /api {
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 $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Prefix /api;
proxy_pass http://evenman-backend:8080/api;
}
location /oauth {
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 $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Prefix /oauth;
proxy_pass http://evenman-backend:8080/oauth;
}
}
}
我试过的
- 重启容器
- 重新启动 Docker 撰写文件
- 重建容器
- 重建 Docker 撰写文件
- 从 Docker 容器更改端口
- Docker 系统修剪
如果您需要有关事物的更多信息,请告诉我,然后我会添加这些信息。