컴퓨터 / Computer

아파치 웹 서버에서 압축 전송하기

feather.png 



일전에 썼던 글(https://www.7-star.net/bbs/board.php?bo_table=talk_computer&wr_id=776)에서 보완할 사항이 많아서 새 글로 등록을 함.


기본적으로는 아파치의 mod_deflate 를 이용하여 압축 전송하는데, 설정에 차이가 있다.


httpd.conf 에 아래 항목을 추가한다. 


 <Location />

# 필터를 추가한다

SetOutputFilter DEFLATE


# Netscape 4.x에 문제가 있다...

BrowserMatch ^Mozilla/4 gzip-only-text/html


# Netscape 4.06-4.08에 더 문제가 있다

BrowserMatch ^Mozilla/4\.0[678] no-gzip


# MSIE은 Netscape라고 자신을 알리지만, 문제가 없다

# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html


# 주의: 아파치 2.0.48까지 mod_setenvif의 버그때문에

# 위의 정규표현식은 동작하지 않는다. 원하는 효과를

# 얻기위해 다음과 같이 수정하여 사용한다:

BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html


# 이미지를 압축하지 않는다

SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|bmp|zip|gz|rar|7z)$ no-gzip dont-vary


# 프록시가 잘못된 내용을 전달하지않도록 한다

Header append Vary User-Agent env=!dont-vary

</Location>


혹자는 위 내용 대신에 아래 내용을 넣으면 된다고 한다. 


 <IfModule mod_deflate.c>


AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

DeflateCompressionLevel 9

BrowserMatch ^Mozilla/4 gzip-only-text/html # Netscape 4.xx에는 HTML만 압축해서 보냄
BrowserMatch ^Mozilla/4\.0[678] no-gzip # Netscape 4.06~4.08에는 압축해서 보내지 않음
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html # 자신을 Mozilla로 알리는 MSIE에는 그대로 압축해서 보냄

##예외 설정
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|bmp|zip|gz|rar|7z)$ no-gzip dont-vary

####로그설정.
##DeflateFilterNote Input instream
##DeflateFilterNote Output outstream
##DeflateFilterNote Ratio ratio
##
##LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
##CustomLog logs/deflate_log deflate 
</IfModule>



위 항목을 제대로 쓸려면 아래 Module 을 활성화해야 한다.


LoadModule deflate_module modules/mod_deflate.so

LoadModule headers_module modules/mod_headers.so

LoadModule filter_module modules/mod_filter.so



아파치를 다시 시작한 후에 아래 사이트에서 확인해 보면 된다.



http://www.whatsmyip.org/http-compression-test/






관련 링크 

 - https://httpd.apache.org/docs/2.4/ko/mod/mod_deflate.html

 -  https://www.playnexacro.com/#show:techtip:182 

 - https://www.7-star.net/bbs/board.php?bo_table=talk_computer&wr_id=905

 - https://www.7-star.net/bbs/board.php?bo_table=talk_computer&wr_id=776

Comments

차량용 햇빛 창문 아기 블라인드 가리개 가림막 차
칠성상회
시스맥스 모도 스토리지 박스 다용도 정리함 보관함
칠성상회
[모리스] 노크식네임펜S(흑색 1자루 0.7mm)
칠성상회
수기장부 200P 보조부 보조장부
바이플러스