Nginx - 1 - 单页面静态网站配置
静态网站配置

刷新页面,默认重定向到Index.html

静态目录(static),找不到默认404

server {
  listen       8080;
  server_name  localhost;

  client_max_body_size 10m;
  client_header_buffer_size 256k;
  large_client_header_buffers 4 256k;

  root /opt/vue;

  location /faq {
      default_type text/html;
      return 200 '<!--faq-->';
  }

  location /static/ {
      try_files \$uri \$uri =404;
  }

  location / {
      add_header Cache-Control 'no-cache';
      try_files \$uri \$uri /index.html;
  }
}

附加问题

400 Bad Request Request Header Or Cookie Too Large

Nginx配置不当可能导致的安全问题

React部署于Nginx环境中刷新后404解决方案


最后修改于 2023-03-10

此篇文章的评论功能已经停用。