dockerized vujs nginx 403错误:“/etc/nginx/html/&quort”目录索引被禁止

发布于 2025-02-07 10:28:54 字数 1708 浏览 2 评论 0原文

我正在尝试使用Nginx对Vuejs应用进行扩展,但它一直向我展示此错误。

[error] 8#8: *1 directory index of "/etc/nginx/html/" is forbidden, client: x.x.x.x, server: localhost, request: "GET / HTTP/1.1", host: "x.x.x.x:80"
[error] 8#8: *1 directory index of "/etc/nginx/html/" is forbidden, client: x.x.x.x, server: localhost, request: "GET / HTTP/1.1", host: "x.x.x.x:80"
[error] 8#8: *1 directory index of "/etc/nginx/html/" is forbidden, client: x.x.x.x, server: localhost, request: "GET / HTTP/1.1", host: "x.x.x.x:80"

这是我的docker和nginx配置:

dockerfile

FROM nginx:1.17-alpine

# Copy built app into nginx 
COPY /dist /etc/nginx/html/studio

# copy nginx conf
COPY nginx.conf /etc/nginx/nginx.conf

nginx.conf

user 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;
  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"';
  sendfile        on;
  keepalive_timeout  65;

  map $http_user_agent $loggable {
    "~kube-probe/.*"        0;
    default                 1;
  }
  access_log  /var/log/nginx/access.log main if=$loggable;

  server {
    listen       80;
    server_name  localhost;

    location /studio/ {
      try_files $uri $uri/ /studio/index.html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   html;
    }
  }
}

当我访问浏览器时显示:503服务暂时不可用-Nginx

I am trying to dockerize a VueJS app using nginx , but it keeps showing me this error .

[error] 8#8: *1 directory index of "/etc/nginx/html/" is forbidden, client: x.x.x.x, server: localhost, request: "GET / HTTP/1.1", host: "x.x.x.x:80"
[error] 8#8: *1 directory index of "/etc/nginx/html/" is forbidden, client: x.x.x.x, server: localhost, request: "GET / HTTP/1.1", host: "x.x.x.x:80"
[error] 8#8: *1 directory index of "/etc/nginx/html/" is forbidden, client: x.x.x.x, server: localhost, request: "GET / HTTP/1.1", host: "x.x.x.x:80"

This my docker and nginx configuration :

Dockerfile

FROM nginx:1.17-alpine

# Copy built app into nginx 
COPY /dist /etc/nginx/html/studio

# copy nginx conf
COPY nginx.conf /etc/nginx/nginx.conf

nginx.conf

user 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;
  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"';
  sendfile        on;
  keepalive_timeout  65;

  map $http_user_agent $loggable {
    "~kube-probe/.*"        0;
    default                 1;
  }
  access_log  /var/log/nginx/access.log main if=$loggable;

  server {
    listen       80;
    server_name  localhost;

    location /studio/ {
      try_files $uri $uri/ /studio/index.html;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   html;
    }
  }
}

When I access the browser it shows : 503 Service Temporarily Unavailable - nginx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文