https://getgrav.org/blog/raspberrypi-nginx-php7-dev
隐藏Nginx的版本号
https://www.quyu.net/info/467.html
一、隐藏Nginx版本号
第一步:
vi /usr/local/nginx/conf/nginx.conf
在http{}中加入
server_tokens off;
第二歩:
vi /usr/local/nginx/conf/fastcgi_params
将里面的
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
修改为:
fastcgi_param SERVER_SOFTWARE nginx;
二、隐藏PHP版本号
vi php.ini
找到:
expose_php = On;
修改为:
expose_php = Off;
重启!
三、伪装Nginx
vi /src/core/nginx.h
修改其中:
#define NGINX_VERSION “1.0″
#define NGINX_VER “GWS/” NGINX_VERSION
重新编译nginx;
以上就是伪装Nginx,隐藏Nginx、PHP版本号并提升服务器安全性全部过程。
Nginx开启子网站
https://www.digitalocean.com/community/questions/how-to-create-subdomain-with-nginx-server-in-the-same-droplet
sudo nano /etc/nginx/sites-available/sub.test.com
Inside the configuration place and edit the following:
server {
listen 80;
root /var/www/sub.test.com;
index index.html index.htm index.nginx-debian.html;
server_name sub.test.com www.sub.test.com;
location / {
try_files $uri $uri/ =404;
}
}
<^>Inside this configuration modify the following to your specific setup:
- root (your website file directory)
- server_name (your website domain)<^>
Now you need to enable the configuration, make a symlink to the enabled sites:
ln -s /etc/sites-available/sub.test.com /etc/sites-enabled/sub.test.com
Last thing to do is restart nginx:
service nginx restart
Nginx 开启目录浏览功能
http://blog.licess.com/nginx-autoindex/
Nginx默认是不允许列出整个目录的。如需此功能,打开nginx.conf文件或你要启用目录浏览虚拟主机的配置文件,在server或location 段里添加上autoindex on;来启用目录流量,下面会分情况进行说明。
另外Nginx的目录流量有两个比较有用的参数,可以根据自己的需求添加:
autoindex_exact_size off;
默认为on,显示出文件的确切大小,单位是bytes。
改为off后,显示出文件的大概大小,单位是kB或者MB或者GB
autoindex_localtime on;
默认为off,显示的文件时间为GMT时间。
改为on后,显示的文件时间为文件的服务器时间
1、整个虚拟主机开启目录流量
在server段添加
location / {
autoindex on;
autoindex_localtime on; #之类的参数写这里
}
2、单独目录开启目录流量
2.1:直接二级目录开启目录流量
location /down/ {
autoindex on;
}
2.2:虚拟目录开启目录流量
location /down/ {
alias /home/wwwroot/lnmp/test/;
autoindex on;
}