cat << EOF > /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
Category: Linux
Nginx 隐藏版本号
修改相关配置文件
vi /usr/local/nginx/conf/nginx.conf
http模块加入 server_tokens off;
vi /usr/local/nginx/conf/fastcgi.conf
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
改为
fastcgi_param SERVER_SOFTWARE nginx;
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -s reload
修改前后对比
Windows、Linux指定host IP测试
Windows
修改 C:\Windows\System32\Drivers\etc\hosts
新增【IP 域名】,多个需回车换行,例:
127.0.0.1 www.baidu.com
Ctrl + S保存,打开无痕浏览器,F12进行测试
Linux
修改 /etc/hosts
新增【IP 域名】,多个需回车换行,例:
127.0.0.1 www.baidu.com
:wq保存,curl进行测试