nginx修改Banner

在安装之前

1
2
cd nginx-1.22.0
vim src/core/nginx.h

image-20220727162934378

配置

1
2
sudo yum install -y make gcc gcc-c++ pcre-devel zlib-devel
./configure --prefix=/opt/nginx/nginx

编译安装

1
2
3
4
5
6
7
8
9
10
11
make
make install
# 如果使用nginx用户安装,需要修改 nginx.conf 中的用户
# sed -i 's/#user nobody;/user nginx;/' /opt/nginx/nginx/conf/nginx.conf
# 默认情况下Linux的1024以下端口是只有root用户才有权限占用 ,所以80 端口改为 50080
# firewall配置端口转发
sudo firewall-cmd --permanent --add-masquerade
# sudo firewall-cmd --permanent --zone=public --add-forward-port=port=80:proto=tcp:toaddr=127.0.0.1:toport=50080
sudo firewall-cmd --permanent --zone=public --add-forward-port=port=80:proto=tcp:toport=50080
sudo firewall-cmd --reload
/opt/nginx/nginx/sbin/nginx -c /opt/nginx/nginx/conf/nginx.conf

开启防火墙

1
2
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --reload

问题

问题

1
checking for C compiler ... not found

安装

1
sudo yum install -y gcc

问题

1
the HTTP rewrite module requires the PCRE library

安装

1
sudo yum install -y  pcre-devel 

每日一个日志文件

1
2
3
4
5
6
7
http {
map $time_iso8601 $logdate {
'~^(?<ymd>\d{4}-\d{2}-\d{2})' $ymd;
default 'date-not-found';
}
access_log /opt/nginx/nginx/logs/access-$logdate.log json_log;
}

本文地址: https://github.com/maxzhao-it/blog/post/12e2d0c0/