1
0
mirror of https://github.com/142vip/408CSFamily.git synced 2026-02-03 02:23:38 +08:00
Files
408CSFamily/nginx.conf

49 lines
2.0 KiB
Nginx Configuration File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 参考https://www.likecs.com/ask-1256888.html
user root;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile off;
access_log off; ## 关闭正常访问日志
keepalive_timeout 3000;
server {
listen 80;
server_name localhost;
#access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log error;
## 静态资源代理
location / {
gzip on; #开启或关闭gzip on off
gzip_disable "msie6"; #不使用gzip IE6
gzip_min_length 100k; #gzip压缩最小文件大小超出进行压缩自行调节
gzip_buffers 4 16k; #buffer 不用修改
gzip_comp_level 8; #压缩级别:1-10数字越大压缩的越好时间也越长
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; # 压缩文件类型
# root 根目录默认nginx镜像的html文件夹可以指定其他
root /usr/share/nginx/html;
index index.html index.htm;
# 确保能够处理前端路由,并在找不到对应文件或目录时返回 index.html 文件,让前端应用接管路由处理。
# 这对于使用前端框架(如 Vue.js、React、Angular 等)开发的单页应用非常有用
# 如果vue-router使用的是history模式需要设置这个
# try_files $uri $uri/ /index.html;
}
## 错误页面
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
## 服务端异常跳转页面
location = /50x.html {
root /usr/share/nginx/html;
}
}
}