0 Star 0 Fork 23

jarstick/test-platform-api

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
nginx.conf 3.81 KB
一键复制 编辑 原始数据 按行查看 历史
向前走 提交于 2023-12-04 10:38 . 更新
user nginx;
worker_processes 1;
error_log /test/api-test/error.log warn; # 路径自定义
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /usr/local/nginx/conf/mime.types; #文件扩展名与文件类型映射表
default_type application/octet-stream; # 默认文件类型,默认为text/plain
# 设定日志格式
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 /test/api-test/access.log main; # 路径自定义
sendfile on; # 允许sendfile方式传输文件,默认为off,可以在http块,server块,location块。
# sendfile_max_chunk 100k; # 每个进程每次调用传输数量不能大于设定的值,默认为0,即不设上限。
#tcp_nopush on;
keepalive_timeout 75; # 连接超时时间,默认为75s,可以在http,server,location块。
gzip on; # 开启gzip
gzip_min_length 1k; # 启用gzip压缩的最小文件,小于设置值的文件将不会压缩
gzip_comp_level 4; # gzip 压缩级别,1-10,数字越大压缩的越好,也越占用CPU时间。一般设置1和2
gzip_static on; # 是否开启gzip静态资源
# 进行压缩的文件类型。javascript有多种形式。其中的值可以在 mime.types 文件中找到。
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on; # 是否在http header中添加Vary: Accept-Encoding,建议开启
gzip_disable "MSIE [1-6]\."; # 禁用IE 6 gzip
# 设置缓存路径并且使用一块最大100M的共享内存,用于硬盘上的文件索引,包括文件名和请求次数,每个文件在1天内若不活跃(无请求)则从硬盘上淘汰,硬盘缓存最大10G,满了则根据LRU算法自动清除缓存。
proxy_cache_path /home/nginx levels=1:2 keys_zone=imgcache:100m inactive=1d max_size=10g;
client_max_body_size 8m; # 上传文件的大小限制 默认1m
#include /etc/nginx/conf.d/*.conf;
server {
keepalive_requests 120; # 单连接请求上限次数。
listen 80; # nginx监听端口
server_name api-test; # 监听地址
charset utf-8;
client_max_body_size 75M;
# error_page 500 502 503 504 /50x.html; # 定义错误提示页面
# 把请求来源ip放在头部信息里面发送给后端
proxy_set_header Host $host;
proxy_set_header X-Forwarded-From $remote_addr; # 请求来源ip,可能是代理ip,不一定是真实ip
proxy_set_header X-Forwarded-History $proxy_add_x_forwarded_for; # 获取到结果例如:xx.x.x.xx, xx.xx.xx.x,第一个是用户的真实IP,第二个是一级代理的IP,依此类推。
proxy_set_header X-Forwarded-Proto $scheme; # 表示客户端真实的协议(http还是https)
#指定修改被代理服务器返回的响应头中的location头域跟refresh头域数值
#如果使用"default"参数,将根据location和proxy_pass参数的设置来决定。
#proxy_redirect [ default|off|redirect replacement ];
proxy_redirect off;
# /开头的请求的转发地址
location / {
root /test/api-test/front/; # 前端dist包的位置
index index.html;
expires 30d; # 过时间设置为30天,静态文件不怎么更新,过期可以设大一点, 如果频繁更新,则可以设置得小一点。
}
# /api开头的请求的转发地址
location ^~ /api/ {
proxy_pass http://localhost:8024/api/; # 此处需写明ip地址,用127.0.0.1时无效
}
location /files {
alias /home/files/;
autoindex on;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/jarstick/test-platform-api.git
[email protected]:jarstick/test-platform-api.git
jarstick
test-platform-api
test-platform-api
master

搜索帮助