nginx实战演练

目录

一.Nginx架构和安装(未完待续)

<1>.Nginx概述

<2>.Nginx架构和进程

<3>.Nginx模块

<4>.Nginx安装(编译安装)

二.Nginx基础配置

<1>.关闭debug

<2>.将nginx软件添加到环境变量

<3>.开机自启动脚本

<4>.nginx的平滑升级及版本回滚(未完待续)

三.Nginx核心配置

<1>.实现nginx的高并发配置

<2>.root和alias(未完待续)

<3>.location详细使用(未完待续)

<4>.账户认证功能

<5>.自定义错误页面

<6>.自定义错误日志

<7>.检测文件是否存在

<8>.长连接配置

<9>.作为下载服务器

四.Nginx高级配置

<1>.状态页

<2>.压缩功能


一.Nginx架构和安装(未完待续)

<1>.Nginx概述

<2>.Nginx架构和进程

<3>.Nginx模块

<4>.Nginx安装(编译安装)

        源码安装需要提前准备标准的编译器,GCC的全称是(GNU Compiler collection),其有GNU开发,并以GPL即LGPL许可,是自由的类UNIX即苹果电脑Mac OS X操作系统的标准编译器,因为GCC原本只能处理C语言,所以原名为GNU C语言编译器,后来得到快速发展,可以处理C++,Fortran,pascal,objective C,java以及Ada等其他语言,此外还需要Automake工具,以完成自动创建Makefile的工作,Nginx的一些模块需要依赖第三方库,比如: pcre(支持rewrite),zlib(支持gzip模块)和openssl(支持ssl模块)等。
1.安装nginx模块需要依赖的模块
[root@nginx ~]# dnf install gcc pcre-devel zlib-devel openssl-devel -y

2.解压上传的nginx压缩包

[root@nginx ~]# tar zxf nginx-1.24.0.tar.gz

3.创建了一个名为nginx的用户,该用户没有家目录,并且被配置为不能通过/sbin/nologin登录,用于运行Nginx的系统账户。

[root@nginx ~]# useradd -s /sbin/nologin -M nginx

4.cd到解压后的目录下可以看到包含的文件

[root@nginx ~]# cd nginx-1.24.0/
[root@nginx nginx-1.24.0]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src

5.检查系统环境,确保所有必要的依赖都已安装,并准备编译软件

[root@nginx nginx-1.24.0]# ./configure --prefix=/usr/local/nginx \
> --add-module=/root/echo-nginx-module-0.63    # 添加echo模块
> --user=nginx \                               # 指定nginx运行用户   
> --group=nginx \                              # 指定nginx运行组
> --with-http_ssl_module \                     # 支持https://
> --with-http_v2_module \                      # 支持http版本2
> --with-http_realip_module \                  # 支持ip透传
> --with-http_stub_status_module \             # 支持状态页面
> --with-http_gzip_static_module \             # 支持压缩
> --with-pcre \                                # 支持正则
> --with-stream \                              # 支持tcp反向代理
> --with-stream_ssl_module \                   # 支持tcp的ssl加密
> --with-stream_realip_module                  # 支持tcp的透传ip

6.开始编译并将编译好的文件安装到指定目录

[root@nginx nginx-1.24.0]# make && make install 

二.Nginx基础配置

<1>.关闭debug

1.估算nginx的磁盘空间使用量,此时所占空间较大

[root@nginx ~]# du -sh nginx-1.24.0
26M	nginx-1.24.0

2.关闭nginx服务的debug功能

[root@nginx nginx-1.24.0]# vim auto/cc/gcc

3.重新安装编译

[root@nginx nginx-1.24.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module
[root@nginx nginx-1.24.0]# make && make install 

<2>.将nginx软件添加到环境变量

1.把nginx软件的命令执行路径添加到环境变量中

[root@nginx nginx-1.24.0]# vim ~/.bash_profile 
export PATH=$PATH:/usr/local/nginx/sbin

2.重新加载文件生效

[root@nginx nginx-1.24.0]# source ~/.bash_profile 

3.此时可以使用nginx命令查看版本

[root@nginx nginx-1.24.0]# nginx -v
nginx version: nginx/1.24.0

<3>.开机自启动脚本

1.编写自启动脚本

[root@nginx ~]# vim /lib/systemd/system/nginx.service 
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true[Install]
WantedBy=multi-user.target

2.重新加载文件并开启nginx服务

[root@nginx ~]# systemctl daemon-reload 
[root@nginx ~]# systemctl start nginx.service 

<4>.nginx的平滑升级及版本回滚(未完待续)

1.将旧 Nginx 二进制文件换成新 Nginx 程序文件(注意先备份 )
2.向 master 进程发送 USR2 信号
3.master 进程修改 pid 文件名加上后缀 .oldbin, 成为 nginx.pid.oldbin
4.master 进程用新 Nginx 文件启动新 master 进程成为旧 master 的子进程 , 系统中将有新旧两个 Nginx
5.进程共同提供 Web 服务 , 当前新的请求仍然由旧 Nginx worker 进程进行处理 , 将新生成的 master
程的 PID 存放至新生成的 pid 文件 nginx.pid
6.向旧的 Nginx 服务进程发送 WINCH 信号,使旧的 Nginx worker 进程平滑停止
7.向旧 master 进程发送 QUIT 信号,关闭老 master ,并删除 Nginx.pid.oldbin 文件
8.如果发现升级有问题 , 可以回滚∶向老 master 发送 HUP ,向新 master 发送 QUIT

三.Nginx核心配置

<1>.实现nginx的高并发配置

1.查看用户进程的文件限制,此时是1024

[root@nginx ~]# sudo -u nginx ulimit -n
1024

2.压力测试

(1).100个请求同时发送,总共发送500条,0条失败,测试成功

[root@nginx ~]# ab -n 500 -c 100 http://172.25.254.100/index.html

(2).2000个请求同时发送,总共发送50000条,576条失败,测试失败

[root@nginx ~]# ab -n 50000 -c 2000 http://172.25.254.100/index.html

3.修改pam限制

[root@nginx ~]# vim /etc/security/limits.conf 

4.进入配置文件设置最大并发连接数为100000并重载文件

[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
events {worker_connections  100000;         #设置单个工作进程的最大并发连接数
}
[root@nginx ~]# nginx -s reload
[root@nginx ~]# sudo -u nginx ulimit -n
100000

5.压力测试:2000个请求同时发送,总共发送50000条,0条失败,测试成功

[root@nginx ~]# ab -n 50000 -c 2000 http://172.25.254.100/index.html

<2>.root和alias(未完待续)

root:指定web的家目录,在定义location的时候,文件的绝对路径等于 root+location
alias:定义路径别名,会把访问的路径重新定义到其指定的路径,文档映射的另一种机制;仅能用于
location上下文,此指令使用较少
注意: root, 给定的路径对应于 location 中的 /uri 左侧的 /
           alias , 给定的路径对应于 location 中的 /uri 的完整路径
1.使用epoll事件驱动并将子配置文件目录映射到主配置文件中,重载文件
[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
events {worker_connections  100000;use epoll;                                #使用epoll事件驱动
}http  {######include "/usr/local/nginx/conf.d/*.conf"; #在响应报文中将指定的文件扩展名映射至MIME对应的类型######
}
[root@nginx ~]# nginx -s reload

2.创建子配置文件并写入规则,重载文件

[root@nginx ~]# mkdir -p /usr/local/nginx/conf.d
[root@nginx ~]# vim /usr/local/nginx/conf.d/vhost.conf 
server {listen 80;server_name www.rhel9.org;root /data/web/html;index index.html;
}
[root@nginx ~]# nginx -s reload

3.写入测试文字

[root@nginx ~]# echo www.rhel9.org > /data/web/html/index.html 

4.测试:记得做本地解析

<3>.location详细使用(未完待续)

<4>.账户认证功能

1.创建用户,完成后可查看信息

[root@nginx ~]# htpasswd -cm /usr/local/nginx/.htpasswd admin
New password: 
Re-type new password: 
Adding password for user admim[root@nginx ~]# htpasswd -m /usr/local/nginx/.htpasswd liu
New password: 
Re-type new password: 
Adding password for user liu[root@nginx ~]# cat /usr/local/nginx/.htpasswd 
admin:$apr1$okMzYJLu$Sk/0N1AUZoDjgpldJUi2a0
liu:$apr1$DMbv5BB8$HbeB4TMW9UZfAScnzjkq.1

2.创建文件并写入测试文字

[root@nginx ~]# mkdir /data/web/liu
[root@nginx ~]# echo liu > /data/web/liu/index.html 

3.子配置文件中写入规则并重启

[root@nginx ~]# vim /usr/local/nginx/conf.d/vhost.conf 
        location /liu {root /data/web;auth_basic "login password !!!";                   #用户在浏览器看到的认证信息提示auth_basic_user_file "/usr/local/nginx/.htpasswd"; #http认证文件路径}
[root@nginx ~]# nginx -s reload

4.浏览器测试

<5>.自定义错误页面

1.创建文件并写入测试文字

[root@nginx ~]# mkdir -p /data/web/errorpage
[root@nginx ~]# echo sorry! > /data/web/errorpage/40x.html 

2.子配置文件中写入规则并重启

[root@nginx ~]# vim /usr/local/nginx/conf.d/vhost.conf 
server {listen 80;server_name www.rhel9.org;root /data/web/html;index index.html;error_page 404 /40x.html;              #第一步location = /40x.html {root /data/web/errorpage;      #第二步}
}
[root@nginx ~]# nginx -s reload

3.测试

<6>.自定义错误日志

1.创建自定义日志存放目录

[root@nginx ~]# mkdir /var/log/rhel9.org

2.子配置文件中写入规则并重启

[root@nginx ~]# vim /usr/local/nginx/conf.d/vhost.conf 
server {listen 80;server_name www.rhel9.org;root /data/web/html;index index.html;error_page 404 /40x.html;error_log /var/log/rhel9.org/error.log;           #错误日志access_log /var/log/rhel9.org/access.log;         #成功日志location = /40x.html {root /data/web/errorpage;}
}
[root@nginx ~]# nginx -s reload

3.测试

<7>.检测文件是否存在

       try_files 会按顺序检查文件是否存在,返回第一个找到的文件或文件夹(结尾加斜线表示为文件夹),如果所有文件或文件夹都找不到,会进行一个内部重定向到最后一个参数。只有最后一个参数可以引起一 个内部重定向,之前的参数只设置内部 URI 的指向。最后一个参数是回退 URI 且必须存在,否则会出现内 500 错误。
1.创建文件并写入测试文字
[root@nginx ~]# mkdir /data/web/html/error
[root@nginx ~]# echo nobody > /data/web/html/error/default.html
2.子配置文件中写入规则并重启
[root@nginx ~]# vim /usr/local/nginx/conf.d/vhost.conf 
server {listen 80;server_name www.rhel9.org;root /data/web/html;index index.html;error_page 404 /40x.html;error_log /var/log/rhel9.org/error.log;          access_log /var/log/rhel9.org/access.log;        try_files $uri $uri.html $uri/index.html /error/default.html;   #配置location = /40x.html {root /data/web/errorpage;}
}
[root@nginx ~]# nginx -s reload

3.测试

<8>.长连接配置

1.主配置文件中写入规则并重启

[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf

keepalive_timeout    #设定保持连接超时时长,0表示禁止长连接开启长连接后,返回客户端的会话保持时间为60s,单次长连接累计请求达到指定次数请求或65秒就会被断开,第二个数字60为发送给客户端应答报文头部中显示的超时时间设置为60s,如不设置客户端将不显示超时时间。

keepalive_requests   #在一次长连接上所允许请求的资源的最大数量

[root@nginx ~]# nginx -s reload

2.测试:需要用到telnet测试工具

[root@nginx ~]# yum telnet install -y
[root@nginx ~]# telnet www.rhel9.org 80
Trying 172.25.254.100...
Connected to www.rhel9.org.
Escape character is '^]'.
GET / HTTP/1.1                            #输入动作
HOST:www.rhel9.org                        #输入访问HOST#回车
HTTP/1.1 200 OK
Server: nginx/1.24.0
Date: Sat, 18 Aug 2024 0:16:16 GMT
Content-Type: text/html
Content-Length: 15
Last-Modified: Sat, 17 Aug 2024 11:49:12 GMT
Connection: keep-alive
ETag: "669b7a08-f"
Accept-Ranges: bytes

<9>.作为下载服务器

1.创建文件

[root@nginx ~]# mkdir /data/web/download

2.生成一个大小为100MB的文件 

[root@nginx ~]# dd if=/dev/zero of=/data/web/download/liufile bs=1M count=100

3.子配置文件中写入规则并重启

[root@nginx ~]# vim /usr/local/nginx/conf.d/status.conf 
        location /download {         root /data/web;                  autoindex on;                          #自动索引功能autoindex_localtime on;                #on表示显示本机时间而非GMTautoindex_exact_size off;              #计算文件确切大小limit_rate 1024k;                      #限速,默认不限速}
[root@nginx ~]# nginx -s reload

4.测试

四.Nginx高级配置

<1>.状态页

1.子配置文件中写入规则并重启

[root@nginx ~]# vim /usr/local/nginx/conf.d/status.conf 
server {listen 80;server_name status.rhel9.org;root /data/web/html;index index.html;location /status {stub_status;allow 172.25.254.1;deny all;}
}
[root@nginx ~]# nginx -s reload

2.测试

Active connections
当前处于活动状态的客户端连接数
accepts
统计总值, Nginx 自启动后已经接受的客户端请求连接的总数
handled
统计总值, Nginx 自启动后已经处理完成的客户端请求连接总数
requests
统计总值, Nginx自启动后客户端发来的总的请求数,数值越大 , 说明排队现象严重 , 性能不足
Reading
当前状态,正在读取客户端请求报文首部的连接的连接数
Writing
当前状态,正在向客户端发送响应报文过程中的连接数 , 数值越大说明访问量很大
Waiting
当前状态,正在等待客户端发出请求的空闲连接数

<2>.压缩功能

        Nginx 支持对指定类型的文件进行压缩然后再传输给客户端,而且压缩还可以设置压缩比例,压缩后的文件大小将比源文件显著变小,这样有助于降低出口带宽的利用率,降低企业的 IT 支出,不过会占用相 应的 CPU 资源。

1.主配置文件中写入规则并重启

[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
    gzip  on;                       #启用gzip压缩,默认关闭gzip_comp_level 5;              #压缩比由低到高从1到9,默认为1,值越高压缩后文件越小,但是消耗cpu比较高。基本设定未4或者5gzip_min_length 10k;            #gzip压缩的最小文件,小于设置值的文件将不会压缩gzip_http_version 1.1;          #启用压缩功能时,协议的最小版本,默认HTTP/1.1gzip_vary on;                   #如果启用压缩,是否在响应报文首部插入“Vary: Accept-Encoding”,一般建议打开gzip_types text/plain application/javascript application/x-javascript text/css
application/xml text/javascript application/x-httpd-php image/gif image/png;#指明仅对哪些类型的资源执行压缩操作;默认为gzip_types text/html,不用显示指定,否则出错
[root@nginx ~]# nginx -s reload

2.创建两个测试文件

[root@nginx ~]# echo small > /data/web/html/small.html 
[root@nginx ~]# cat /usr/local/nginx/logs/access.log > /data/web/html/big.html 

3.测试:大于10k的文件被压缩了

[root@nginx ~]# du -sh /data/web/html/big.html 
62M	    /data/web/html/big.html
[root@nginx ~]# du -sh /data/web/html/small.html 
4.0K	/data/web/html/small.html

<3>.变量

nginx 的变量可以在配置文件中引用,作为功能判断或者日志等场景使用,变量可以分为内置变量和自定义变量 。 内置变量是由 nginx 模块自带,通过变量可以获取到众多的与客户端访问相关的值。
./configure --prefix=/usr/local/nginx --user=nginx --add-module=echo-nginx-module-0.63 --group=nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre --with-stream --with-stream_ssl_module --with-stream_realip_module 

1.内置变量

(1).子配置文件中写入规则并重启

[root@nginx conf.d]# vim var.conf 
server {listen 80;server_name var.rhel9.org;root /data/web/html;index index.html;location /var {default_type text/html;echo $remote_addr;           #存放了客户端的地址,注意是客户端的公网IPecho $args;                  #变量中存放了URL中的所有参数echo $is_args;               #如果有参数为? 否则为空echo $document_root;         #保存了针对当前资源的请求的系统根目录echo $document_uri;          #保存了当前请求中不包含参数的URI,注意是不包含请求的指令echo $host;                  #存放了请求的host名称echo $remote_port;           #客户端请求Nginx服务器时随机打开的端口,这是每个客户端自己的端口     echo $remote_user;           #已经经过Auth Basic Module验证的用户名echo $request_method;        #请求资源的方式,GET/PUT/DELETE等echo $request_filename;      #当前请求的资源文件的磁盘路径echo $request_uri;           #包含请求参数的原始URI,不包含主机名echo $scheme;                #请求的协议echo $server_protocol;       #保存了客户端请求资源使用的协议的版本echo $server_addr;           #保存了服务器的IP地址echo $server_name;           #虚拟主机的主机名echo $server_port;           #虚拟主机的端口号echo $http_user_agent;       #客户端浏览器的详细信息echo $http_cookie;           #客户端的所有cookie信息echo $cookie_key2;           #name为任意请求报文首部字部cookie的key名}
}
[root@nginx conf.d]# nginx -s reload

 (2).测试

[root@nginx conf.d]# curl -b "key1=liu,key2=liu1" -u liu:liu var.rhel9.org/var?

2.自定义变量

(1).子配置文件中写入规则并重启

[root@nginx conf.d]# vim var.conf 
server {listen 80;server_name var.rhel9.org;root /data/web/html;index index.html;location /var {default_type text/html;set $rhel liu;echo $rhel;}
}
[root@nginx conf.d]# nginx -s reload

(2).测试

[root@nginx conf.d]# curl -b "key1=liu,key2=liu1" -u liu:liu var.rhel9.org/var?

五.Nginx Rewrite 相关功能

        Nginx 服务器利用 ngx_http_rewrite_module 模块解析和处理 rewrite 请求,此功能依靠 PCRE(perl compatible regular expression) ,因此编译之前要安装 PCRE 库, rewrite nginx 服务器的重要功能之一,用于实现 URL 的重写, URL 的重写是非常有用的功能。 比如它可以在我们改变网站结构之后,不需要客户端修改原来的书签,也无需其他网站修改我们的 链接,就可以设置为访问, 另外还可以在一定程度上提高网站的安全性。

<1>.ngx_http_rewrite_module 模块指令

1.if指令

       用于条件匹配判断,并根据条件判断结果选择不同的 Nginx 配置,可以配置在 server location 块中进行配置, Nginx if 语法仅能使用 if 做单次判断,不支持使用 if else 或者 if elif 这样的多重判断,用法如下:
(1). 子配置文件中写入规则并重启
     location /test2 {if ( !-e $request_filename ){              #判断文件是否存在 echo "$request_filename is not exist";     #不存在显示此行,存在显示内容}}

(2).测试

 

2.set指令

       指定 key 并给其定义一个变量,变量可以调用 Nginx 内置变量赋值给 key。另外 set 定义格式为 set $key value value 可以是 text, variables 和两者的组合。
(1). 子配置文件中写入规则并重启
    location /var {default_type text/html;set $rhel liu;echo $rhel;}

(2).测试

3.break指令

        用于中断当前相同作用域 (location) 中的其他 Nginx 配置,与该指令处于同一作用域的 Nginx 配置中,位于它前面的配置生效, 位于后面的 ngx_http_rewrite_module 模块中指令就不再执行, Nginx 服务器在根据配置处理请求的过程中遇到该指令的时候,回到上一层作用域继续向下读取配置, 该指令可以在 server 块和 locationif 块中使用。
注意如果 break 指令在 location 块中后续指令还会继续执行 , 只是不执行 ngx_http_rewrite_module
模块的指令 , 其它指令还会执行。
(1). 子配置文件中写入规则并重启
    location /break {default_type text/html;set $name liu;echo $name;if ( $http_user_agent = "curl/7.76.1" ){break;}set $id 666;echo $id;}
[root@nginx conf.d]# mkdir -p /data/web/html/break
[root@nginx conf.d]# echo break > /data/web/html/break/break.html

(2).测试

4.return指令

       return 用于完成对请求的处理,并直接向客户端返回响应状态码,比如 : 可以指定重定向 URL( 对于特殊重定向状态码, 301/302 ) 或者是指定提示文本内容 ( 对于特殊状态码 403/500 ) ,处于此指令后的所有配 置都将不被执行, return 可以在 server if location 块进行配置。

(1).子配置文件中写入规则并重启

   location /return {default_type text/html;if ( !-e $request_filename){            #如果文件不存在return 301 http://www.baidu.com;    #返回给客户端的URL地址}echo "$request_filename is exist";    }

(2).测试

<2>.rewrite 指令

       通过正则表达式的匹配来改变 URI ,可以同时存在一个或多个指令,按照顺序依次对 URI 进行匹配,rewrite 主要是针对用户请求的 URL 或者是 URI 做具体处理。

1.永久重定向

       域名永久型调整,即域名永远跳转至另外一个新的域名,之前的域名再也不使用,跳转记录可以缓存到客户端浏览器, 永久重定向会缓存 DNS 解析记录 浏览器中有 from disk cache 信息 , 即使 nginx 服务器无法访问 , 浏览器也 会利用缓存进行重定向。

(1).子配置文件中写入规则并重启

[root@nginx conf.d]# mkdir -p /data/web/html/pc
[root@nginx conf.d]# echo cpcpcpcp > /data/web/html/pc/index.html
server {listen 80;server_name www.rhel9.com;root /data/web/html/pc;location / {rewrite / http://www.rhel9.com permanent;}
}

(2).测试 

2.临时重定向

       域名临时重定向,告诉浏览器域名不是固定重定向到当前目标域名,后期可能随时会更改,因此浏览器不会缓存当前域名的解析记录,而浏览器会缓存永久重定向的 DNS 解析记录,这也是临时重定向与永久 重定向最大的本质区别。
server {listen 80;server_name www.rhel9.com;root /data/web/html/pc;location / {rewrite / http://www.rhel9.com redirect;}
}

3.break 与 last

[root@nginx conf.d]# mkdir -p /data/web/html/liu/{test1,test2,break,last}
[root@nginx conf.d]# echo test1 > /data/web/html/liu/test1/index.html
[root@nginx conf.d]# echo test2 > /data/web/html/liu/test2/index.html
[root@nginx conf.d]# echo break > /data/web/html/liu/break/index.html
[root@nginx conf.d]# echo last > /data/web/html/liu/last/index.html
server {listen 80;server_name www.rhel9.org;root /data/web/html/liu;location /break {root /data/web/html/liu;rewrite ^/break/(.*) /test1/$1 last;rewrite ^/test1/(.*) /test2/$1 break;}location /last {root /data/web/html/liu;rewrite ^/last/(.*) /test1/$1 last;rewrite ^/test1/(.*) /test2/$1 last;}location /test1 {default_type text/html;return 666 "new test1";}location /test2 {root /data/web/html/liu;}
}

4.全站加密

cd /usr/local/nginx/
mkdir certs
openssl req  -newkey  rsa:2048 -nodes -sha256 -keyout /usr/local/nginx/certs/timinglee.org.key \
-x509  -days 365 -out /usr/local/nginx/certs/timinglee.org.crt
vim /usr/local/nginx/conf.d/vhosts.confserver {listen 80;listen 443 ssl;server_name www.timinglee.org;root /data/web/html;index index.html;ssl_certificate /usr/local/nginx/certs/timinglee.org.crt;ssl_certificate_key /usr/local/nginx/certs/timinglee.org.key;ssl_session_cache    shared:SSL:1m;ssl_session_timeout  5m;location / {if ( $scheme = http ){rewrite / https://$host redirect;}}
}server {listen 80;listen 443 ssl;server_name www.timinglee.org;root /data/web/html;index index.html;ssl_certificate /usr/local/nginx/certs/timinglee.org.crt;ssl_certificate_key /usr/local/nginx/certs/timinglee.org.key;ssl_session_cache    shared:SSL:1m;ssl_session_timeout  5m;location / {if ( $scheme = http ){rewrite /(.*) https://$host/$1 redirect;}if ( !-e $request_filename ){rewrite /(.*) https://$host/index.html redirect;}}

<3>.防盗链

<html><head><meta http-equiv=Content-Type content="text/html;charset=utf-8"><title>盗链</title>
</head><body><img src="http://www.timinglee.org/images/lee.png" ><h1 style="color:red">欢迎大家</h1><p><a href=http://www.timinglee.org>狂点老李</a>出门见喜</p></body></html>
server {listen 80;server_name lee.timinglee.org;root /webdata/nginx/timinglee.org/lee;location /images {valid_referers none blocked server_names *.timinglee.org ~\.baidu\.;if ($invalid_referer){#return 403;rewrite ^/ http://lee.timinglee.org/daolian.png permanent;}}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/403824.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Qt/C++地图标注点的添加删除移动旋转/指定不同图标和动图/拿到单击信号

一、前言说明 标注点在地图开发中是最常见的应用场景之一&#xff0c;比如在地图上需要显示设备的位置&#xff0c;基本上都是添加标注点&#xff0c;指定图片和尺寸已经经纬度坐标位置。这个功能在每种地图内核中都提供的&#xff0c;这个并没有任何难点&#xff0c;在这个功…

CeresPCL 最小二乘插值(曲线拟合)

一、简介 在多项式插值时,当数据点个数较多时,插值会导致多项式曲线阶数过高,带来不稳定因素。因此我们可以通过固定幂基函数的最高次数 m(m < n),来对我们要拟合的曲线进行降阶。之前的函数形式就可以变为: 既然是最小二乘问题,那么就仍然可以使用Ceres来进行求解。 …

★ C++基础篇 ★ vector 类

Ciallo&#xff5e;(∠・ω< )⌒☆ ~ 今天&#xff0c;我将继续和大家一起学习C基础篇第六章----vector类 ~ 目录 一 vector的介绍及使用 1.1 vector的介绍 1.2 vector的使用 1.2.1 vector的定义 1.2.2 vector iterator 的使用 1.2.3 vector 空间增长问题 1.2.4 vecto…

使用 Fyne 构建 GUI 应用:设置标签文本和自增计数器

引言 Fyne 是一个用 Go 语言编写的跨平台 GUI 框架&#xff0c;它提供了一套丰富的组件来帮助开发者快速构建出漂亮的用户界面。在本文中&#xff0c;我们将通过一个简单的案例来演示如何使用 Fyne 创建 GUI 应用程序&#xff0c;该程序包含设置标签文本和自增计数器的功能。 …

高可用集群keepalived从部署到实战一篇解决

目录 一.高可用集群 1.1 集群类型 1.2 系统可用性 1.3 系统故障 1.4 实现高可用 1.5.VRRP&#xff1a; 1.5.1 VRRP 相关术语 1.5.2 VRRP 相关技术 二.Keepalived 部署 2.1 keepalived 简介 2.2keepalived架构 2.3 Keepalived 环境准备 2.4 Keepalived 相关文件 2.…

Python编写Word文档

目录 0. 安装依赖 1. 创建word文档 2. 添加标题、居中、字体16大小 3. 添加标题一 4. 添加一段话并设置字体颜色 封装函数 5. 换页 6. 插入表格 0. 安装依赖 python-docx1.1.2 1. 创建word文档 from docx import Documentdoc Document() 2. 添加标题、居中、字体1…

智碳云/高能耗企业 水-电-气-热-油-空压机等能源数据采集系统【源码】

智碳云/高能耗企业 水-电-气-热-油-空压机等能源数据采集系统【源码】 介绍基于SpringCloud的能源管理系统-能源管理平台源码-能源在线监测平台-双碳平台源码-SpringCloud全家桶-能管管理系统源码-能管系统软件架构

【记git 重命名文件失败,和正确方法】

【背景】 想要重命名一个文件&#xff0c;并同步到远程 【过程】 1.我是直接把 “驱动增加he.c” 文件重命名为 “驱动增加播放he接口方法” &#xff0c;想着直接提交就会同步重命名git仓记录的文件名。然后就可以推送到远程仓库&#xff0c;同步重命名远程仓库的文件名。 2.然…

全球滑坡(降雨诱发的)数据(有时间属性)

滑坡一般指狭义概念的滑坡,是指构成斜坡的有滑动历史和滑动可能性的岩、土体边坡,在重力作用下伴随着其下部软弱面(带)上的剪切作用过程而产生整体性运动的现象。 滑坡的发育阶段滑坡的发生、发展过程是有阶段性的。根据大量的现场实际资料、观测成果、滑坡模型试验和相关的岩土…

ant design pro v6 如何做好角色管理

先上图&#xff1a; 整个角色管理是如何做的吗&#xff1f; 首先你要处理后端&#xff0c;要先把角色存到用户那。 这是用户管理部分的内容&#xff1a; 可以看到一个用户是有多个角色的。 看到没有&#xff0c;存的是数组 数组的是一个 role 对象 role 对象是这样&#xf…

【专题】2024年7月人工智能AI行业报告合集汇总PDF分享(附原数据表)

原文链接:https://tecdat.cn/?p37350 随着人工智能技术的飞速发展&#xff0c;AI已经成为当今时代的重要驱动力。本报告将聚焦于人工智能AI行业的最新动态&#xff0c;涵盖客户服务、体验营销、资产管理以及国产AI大模型应用等多个领域。通过深入研究和分析&#xff0c;我们…

C++ 设计模式——抽象工厂模式

抽象工厂模式 抽象工厂模式 抽象工厂模式主要组成部分代码实现抽象工厂模式模式的 UML 图抽象工厂模式 UML 图解析优点和缺点适用场景 抽象工厂模式提供一个接口&#xff0c;用于创建一系列相关或相互依赖的对象&#xff0c;而无需指定它们的具体类。它通常用于需要创建多个产品…

2024年必读!《大模型应用开发极简入门》—— 一书掌握LLM大模型精髓

大家好&#xff0c;今天给大家推荐一本大模型应用开发入门书籍《大模型应用开发极简入门》&#xff0c;本书对很多AI概念做了讲解和说明&#xff01; 朋友们如果有需要 《大模型应用开发极简入门》&#xff0c;扫码获取~ 本书主要讲解了以下几个方面的大模型技术&#xff1a; …

[图解]片段16 ESS状态机图-SysMLEA建模住宅安全系统

1 00:00:00,220 --> 00:00:03,580 然后我们看初始这里 2 00:00:03,590 --> 00:00:09,500 有一个指向它的一个迁移的事件 3 00:00:09,710 --> 00:00:13,730 站点可用&#xff0c;这个实际上是错误的 4 00:00:14,020 --> 00:00:15,050 这不是事件 5 00:00:15,900…

NCSN公式推导(一)

通过估计数据分布的梯度进行生成建模 Paper Title&#xff1a;Generative Modeling by Estimating Gradients of the Data Distribution Paper是斯坦福大学发表在NIPS 2019的工作 Paper地址 Abstract 我们引入了一种新的生成模型&#xff0c;其中样本通过朗之万动力学生成&…

Power Query抓取多页数据导入到Excel

原文链接 举例网站&#xff1a;http://vip.stock.finance.sina.com.cn/q/go.php/vLHBData/kind/ggtj/index.phtml?last5&p1 操作步骤 &#xff08;版本为&#xff1a;Excel2010&#xff09;&#xff1a; Step-01&#xff1a;单击【Power Query】-【从Web】&#xff0c;…

日期类代码实现-C++

一、目标 通过前面对类和对象的介绍我们可以自己通过C代码初步实现一个简单的日期类。 实现的主要操作有&#xff1a; 1.日期类的构造函数 2.日期类的拷贝构造函数&#xff08;在头文件中实现&#xff09; 3.日期类的比较运算符重载 4.日期类的计算运算符重载 5.流插入运…

【Linux】 gdb-调试器初入门(简单版使用)

&#x1f525;系列文章&#xff1a;《Linux入门》 目录 一、背景 二、什么是GDB &#x1f337;定义 &#x1f337;GDB调试工具---提供的帮助 三、GDB的安装教程-Ubuntu &#x1f337;gdb的安装 四、哪类程序可被调试 &#x1f337;程序的发布方式 &#x1f337;Debug版…

Vscode——如何实现 Ctrl+鼠标左键 跳转函数内部的方法

一、对于Python代码 安装python插件即可实现 二、对于C/C代码 安装C/C插件即可实现

5.3 表结构设计与数据完整性

欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;欢迎订阅相关专栏&#xff1a; 工&#x1f497;重&#x1f497;hao&#x1f497;&#xff1a;野老杂谈 ⭐️ 全网最全IT互联网公司面试宝典&#xff1a;收集整理全网各大IT互联网公司技术、项目、HR面试真题.…