十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Nginx的ngx_http_gzip_module压缩模块提供对文件内容压缩的功能,允许Nginx服务器将输出内容在发送客户端之前进行压缩,以节约网站带宽,提升用户的访问体验,默认已经安装。可在配置文件中加入相应的压缩功能参数对压缩性能进行优化。
从网站建设到定制行业解决方案,为提供成都做网站、网站设计、外贸营销网站建设服务体系,各种行业企业客户提供网站建设解决方案,助力业务快速发展。创新互联将不断加快创新步伐,提供优质的建站服务。
[root@localhost ~]# systemctl stop firewalld.service //关闭防火墙
[root@localhost ~]# setenforce 0 //关闭增强性安全功能
[root@localhost ~]#
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css image/jpeg image/png image/gif application/xml text/javascript application/x-httpd-php application/javasrcipt application/json;
gzip_disable "MSIE [1-6]\."; //IE浏览器6版本以上开启压缩功能
gzip_vary on;
[root@localhost ~]# service nginx restart //重启服务
[root@localhost ~]#
[root@localhost ~]# mkdir /mnt/tools
[root@localhost ~]# mount.cifs //192.168.100.50/tools /mnt/tools/
Password for root@//192.168.100.50/tools:
[root@localhost ~]# cp /mnt/tools/forbid.png /usr/local/nginx/html/ //防盗链图片
[root@localhost ~]# cp picture.jpg /usr/local/nginx/html/ //网站图片
[root@localhost ~]# cd /usr/local/nginx/html/
[root@localhost html]# ls
50x.html forbid.png index.html picture.jpg
[root@localhost html]#
[root@localhost html]# vim index.html
Welcome to nginx!
//添加
[root@localhost html]#
[root@localhost html]# yum install bind -y
..........//省略安装过程
[root@localhost html]#
[root@localhost html]# vim /etc/named.conf
options {
listen-on port 53 { any; }; //将127.0.0.1改为any
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; }; //将localhost改为any
[root@localhost html]#
[root@localhost html]# vim /etc/named.rfc1912.zones
zone "abc.com" IN { //添加区域
type master;
file "abc.com.zone";
allow-update { none; };
};
[root@localhost html]#
[root@localhost html]# cd /var/named/
[root@localhost named]# ls
data dynamic named.ca named.empty named.localhost named.loopback slaves
[root@localhost named]# cp -p named.localhost abc.com.zone //复制一份模板并重命名
[root@localhost named]#
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
www IN A 192.168.52.131 //添加解析地址
[root@localhost named]# systemctl start named //开启服务
[root@localhost named]#
盗链网站
this is test web
//盗链路径
[root@localhost named]# vim /usr/local/nginx/conf/nginx.conf
location ~*\.(jpg|gif|swf)$ {
valid_referers none blocked *.abc.com abc.com;
if ( $invalid_referer ) {
rewrite ^/ http://www.abc.com/forbid.png;
}
}
[root@localhost named]# service nginx restart
[root@localhost named]#