Nginx配置防盗链(详细了解如何配置nginx防盗链)

 

worker_processes 1; #允许进程数量,建议设置为cpu核心数或者auto自动检测,注意Windows服务器上虽然可以启动多个processes,但是实际只会用其中一个

events {
#单个进程最大连接数(最大连接数=连接数*进程数)
#根据硬件调整,和前面工作进程配合起来用,尽量大,但是别把cpu跑到100%就行。
worker_connections 1024;
}


http {
#文件扩展名与文件类型映射表(是conf目录下的一个文件)
include mime.types;
#默认文件类型,如果mime.types预先定义的类型没匹配上,默认使用二进制流的方式传输
default_type application/octet-stream;

#sendfile指令指定nginx是否调用sendfile 函数(zero copy 方式)来输出文件,对于普通应用,必须设为on。如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络IO处理速度。
sendfile on;

#长连接超时时间,单位是秒
keepalive_timeout 65;

#定义一组服务器
upstream httpds{
server 192.168.8.102 weight=10;
server 192.168.8.103 weight=1;
}

#虚拟主机的配置
server {
#监听端口
listen 80;
#域名,可以有多个,用空格隔开
server_name test80.xzj520520.cn;

#配置根目录以及默认页面
location / {
proxy_pass http://httpds;
# root /www/test80;
# index index.html index.htm;
}

#出错页面配置
error_page 500 502 503 504 /50x.html;
#/50x.html文件所在位置
location = /50x.html {
root html;
}

}

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 文章转载:https://hashnode.blog.csdn.net/article/details/124530514

posted @ 2023-08-11 09:56  冯坤大神  阅读(234)  评论(0编辑  收藏  举报