Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Apache Page Optimization-Page Compression

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Apache Page and Security Optimization Apache Page Optimization

1. Web page compression

two。 Web caching

Apache security optimization

1. Configure hotlink protection

two。 Hide version information

Overview of Apache web page optimization 1. In enterprises, only the default configuration parameters are used after the deployment of Apache, which will cause a lot of problems on the website. In other words, the default configuration is for the previous lower servers, and the previous configuration is no longer suitable for today's Internet era. 2. In order to meet the needs of enterprises, we need to consider how to improve the performance and stability of Apache, which is the content of Apache optimization 3. 5. Optimize content

Configure web page compression

Selection of working mode and parameter optimization

Configure hotlink protection

Configure hidden version number

Gzip introduces how to configure Apache's web page compression feature, which uses gzip compression algorithm to compress web page content and then transfer it to the client browser:

1. Reduces the number of bytes transmitted through the network and speeds up the loading speed of web pages.

two。 Save traffic and improve users' browsing experience

3.gzip has a better relationship with the crawling tool of search bow | engine.

The compression module of Apache the function modules of Apache to realize web page compression include:

1.mod_gzip module

2.mod_deflate module

Apache 1.x.

1. There is no built-in web page compression technology, but you can use third-party mod _

Apache 2.x

1. At the time of development, the module mod_deflate is built in to replace mod_gzip

Mod_ gzip module and mod_deflate module:

1. Both of them use gzip compression algorithm, which works similarly.

2.mod_deflate compression speed is slightly faster, while mod_gzip compression ratio is slightly higher.

3.mod_gzip has a higher occupation of server CPU.

4. For high-traffic servers, mod_deflate may load faster than mod_gzip

Configure the web page compression feature to first check if the mod_ deflate module is installed:

1. Execute the apachectl-t-D DUMP MODULES command

two。 If there is no deflate module (static) in the output, it is not installed at compile time

Mod_ deflate module

If there is no installation, recompile the installation:

1../configure-enable-deflate...

2.make & & make install

Configure and enable the gzip feature in the configuration httpd.conf:

1.AddOutputFilterByType DEFL ATE text/html text/plain text/css

Text/xml textjavascript

2.DeflateCompressionL evel

3.SetOutputFilter DEFL .ATE

The first line represents what kind of content gzip compression is enabled. The second line represents the compression level. The third line represents the enable deflate module to gzip the output of this site. Demo: compress [root@localhost ~] # mkdir / aaa [root@localhost ~] # mount.cifs / / 192.168.10.12/rpm / aaaPassword for root@//192.168.10.12/rpm: [root@localhost ~] # cd / aaa [root@localhost aaa] # lsLAMP [ Root@localhost aaa] # cd LAMP/ [root@localhost LAMP] # lsapr-1.6.2.tar.gz error.pngapr-util-1.6.0.tar.gz ha.jpgawstats-7.6.tar.gz httpd-2.4.29.tar.bz2cronolog-1.6.2-14.el7.x86_64.rpm mysql-5.6.26.tar.gzDiscuz_X2.5_SC_UTF8 .zip php-5.6.11.tar.bz2 [root@localhost LAMP] # tar jxvf httpd-2.4.29.tar.bz2-C / opt [root@localhost LAMP] # tar zxvf apr-1.6.2.tar.gz-C / opt/ [root@localhost LAMP] # tar zxvf apr-util-1.6.0.tar.gz-C / opt [root@localhost LAMP] # cd / opt/ [root@localhost opt] # lsapr-1.6.2 apr- Util-1.6.0 httpd-2.4.29 rh [root@localhost opt] # mv apr-1.6.2/ httpd-2.4.29/srclib/apr [root@localhost opt] # mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util [root@localhost opt] # yum install gcc gcc-c++ pcre pcre-devel zlib-devel expat-devel-y [root@localhost opt] # cd httpd-2.4.29/ [root@localhost httpd- 2.4.29] # lsABOUT_APACHE CMakeLists.txt INSTALL NWGNUmakefileacinclude.m4 config.layout InstallBin.dsp osApache-apr2.dsw configure LAYOUT READMEApache.dsw configure.in libhttpd.dep README.cmakeapache_probes.d docs libhttpd.dsp README.platformsap.d emacs-style libhttpd.mak ROADMAPbuild httpd.dep LICENSE serverBuildAll.dsp httpd .dsp Makefile.in srclibBuildBin.dsp httpd.mak Makefile.win supportbuildconf httpd.spec modules testCHANGES include NOTICE VERSIONING [root@localhost httpd-2.4.29] #. / configure-- prefix=/usr/local/httpd-- enable-so-- enable-rewrite-- enable-charset-lite-- enable-cgi [root@localhost httpd-2.4.29] # make [root@ Localhost httpd-2.4.29] # make install [root@localhost httpd-2.4.29] # cd / usr/local/httpd/ [root@localhost httpd] # lsbin cgi-bin error icons lib man modulesbuild conf htdocs include logs manual [root@localhost httpd] # cd conf [root@localhost conf] # lsextra httpd.conf magic mime.types original [root@localhost conf] # vim httpd.conf [root@localhost conf] # ln-s / usr/local/httpd/conf/httpd.conf / etc/httpd.conf [root@localhost conf] # vim / etc/httpd.conf / deflate Search for the keyword LoadModule deflate_module modules/mod_deflate.so / / this line needs to remove comments / headers, search for this keyword LoadModule headers_module modules/mod_headers.so / / this line needs to remove comments / filter, search for this keyword LoadModule filter_module modules/mod_filter.so / / this line needs to remove comments / Listen, search for this keyword Listen 192.168.18.128:80#Listen 80/ServerName Search for this keyword ServerName www.kgc.com:80 by the capital letter G to the last line, press o to turn downline to insert AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript text/ipg text/png DeflateCompressionLevel 9 SetOutputFilter DEFLATE// after modification, press Esc to exit Input: wq save and exit [root@localhost conf] # / usr/local/httpd/bin/apachectl-tSyntax OK// to verify whether the syntax is correct [root@localhost conf] # / usr/local/httpd/bin/apachectl start [root@localhost conf] # netstat-ntap | grep 80tcp 0 0192.168.18.128usr/local/httpd/bin/apachectl 80 0.0.0.0 LISTEN 82881/httpd [root@localhost conf] # lsextra Httpd.conf magic mime.types original [root@localhost conf] # cd.. [root@localhost httpd] # lsbin cgi-bin error icons lib man modulesbuild conf htdocs include logs manual [root@localhost httpd] # cd htdocs/ [root@localhost htdocs] # lsindex.html [root@localhost htdocs] # cat index.html It works! [root@localhost htdocs] # cd / usr/local/httpd/bin/ [root@localhost bin] #. / apachectl-t-D DUMP_MODULES | grep "deflate" deflate_module (shared) Verification: enter the other party's IP address in win10 with a browser: 192.168.18.128. At this time, the home page can be displayed: It works!

We can use the package crawl software to see that the crawled web page can support compression. If we want to see compression at this time, we have to add pictures to the page, so that the image compression information will appear when we visit again.

Add a picture to the page: [root@localhost bin] # cd / aaa/LAMP [root@localhost LAMP] # lsapr-1.6.2.tar.gz ha.jpgapr-util-1.6.0.tar.gz httpd-2.4.29.tar.bz2awstats-7.6.tar.gz lf.jpgcronolog-1.6.2-14.el7.x86_64.rpm mysql-5.6.26 .tar.gzDiscuz _ X2.5_SC_UTF8.zip php-5.6.11.tar.bz2error.png [root@localhost LAMP] # cp lf.jpg / usr/local/httpd/htdocs/ copy the picture to the corresponding folder [root@localhost LAMP] # cd / usr/local/httpd/ [root@localhost httpd] # cd htdocs/ [root@localhost htdocs] # lsindex.html lf.jpg [root@localhost htdocs] # vim index.html It works!

/ / make the above changes to the format, insert the image into it, press Esc to exit, enter: wq to save and exit, and then go back to the web page for verification:

After entering the IP address of the other party, you can see the added picture. Through the package crawling software, we can see that there is information about gzip compression at the port in the crawl information with pictures.

The specific process is shown in the following figure:

Conclusion: as long as we embed a format file such as picture or video in the web page, the web page will be compressed and then transmitted to the client of the other party for decompression recognition.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report