Skip to content

공지사항

웹서버 설정 최적화

조회 수 2,422 추천 수 0
# ----------------------------------------------------------------------
# Apache configuration file
# This file is best used in /apache2/httpd.conf, but works (slower) in .htaccess
#
# I've spent quite a bit of time compiling what I find to be optimial to me
# and my server. This file is based on:
# - HTML5BoilerPlate: https://github.com/h5bp/html5-boilerplate/
# - W3 Edge: http://www.w3-edge.com/
# - Yahoo! Best Practices: http://developer.yahoo.com/performance/rules.html
# - Caching Tutorial: http://www.mnot.net/cache_docs/
# - Personal experience
#
# v1.2 / 2013.07.01 / Greg Rickaby
# ----------------------------------------------------------------------



ServerTokens Prod
ServerSignature Off


#mod_expires.conf
LoadModule expires_module modules/mod_expires.so

# ----------------------------------------------------------------------
# Cache Control via HTTP Headers + Expires
# Generation of Expires and Cache-Control HTTP headers according to user-specified criteria
# http://httpd.apache.org/docs/2.0/mod/mod_headers.html
# ----------------------------------------------------------------------

# Expires Defaults
#<IfModule mod_expires.c>
ExpiresActive On
# Set default expires to 2 days
ExpiresDefault A172800
ExpiresByType text/css A31536000
ExpiresByType application/x-javascript A31536000
ExpiresByType text/x-component A31536000
ExpiresByType text/html A3600
ExpiresByType text/richtext A3600
ExpiresByType image/svg+xml A3600
ExpiresByType text/plain A3600
ExpiresByType text/xsd A3600
ExpiresByType text/xsl A3600
ExpiresByType text/xml A3600
ExpiresByType video/asf A31536000
ExpiresByType video/avi A31536000
ExpiresByType image/bmp A31536000
ExpiresByType application/java A31536000
ExpiresByType video/divx A31536000
ExpiresByType application/msword A31536000
ExpiresByType application/vnd.ms-fontobject A31536000
ExpiresByType application/x-msdownload A31536000
ExpiresByType image/gif A31536000
ExpiresByType application/x-gzip A31536000
ExpiresByType image/x-icon A31536000
ExpiresByType image/jpeg A31536000
ExpiresByType application/vnd.ms-access A31536000
ExpiresByType audio/midi A31536000
ExpiresByType video/quicktime A31536000
ExpiresByType audio/mpeg A31536000
ExpiresByType video/mp4 A31536000
ExpiresByType video/mpeg A31536000
ExpiresByType application/vnd.ms-project A31536000
ExpiresByType application/x-font-otf A31536000
ExpiresByType application/vnd.oasis.opendocument.database A31536000
ExpiresByType application/vnd.oasis.opendocument.chart A31536000
ExpiresByType application/vnd.oasis.opendocument.formula A31536000
ExpiresByType application/vnd.oasis.opendocument.graphics A31536000
ExpiresByType application/vnd.oasis.opendocument.presentation A31536000
ExpiresByType application/vnd.oasis.opendocument.spreadsheet A31536000
ExpiresByType application/vnd.oasis.opendocument.text A31536000
ExpiresByType audio/ogg A31536000
ExpiresByType application/pdf A31536000
ExpiresByType image/png A31536000
ExpiresByType application/vnd.ms-powerpoint A31536000
ExpiresByType audio/x-realaudio A31536000
ExpiresByType image/svg+xml A31536000
ExpiresByType application/x-shockwave-flash A31536000
ExpiresByType application/x-tar A31536000
ExpiresByType image/tiff A31536000
ExpiresByType application/x-font-ttf A31536000
ExpiresByType audio/wav A31536000
ExpiresByType audio/wma A31536000
ExpiresByType application/vnd.ms-write A31536000
ExpiresByType application/vnd.ms-excel A31536000
ExpiresByType application/zip A31536000
#</IfModule>

# No caching for dynamic files
#<filesMatch "\.(php|cgi|pl|htm)$">
# ExpiresDefault A0
# Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
# Header set Pragma "no-cache"
#</filesMatch>

# 1 MIN
#<filesMatch "\.(html)$">
# ExpiresDefault A60
# Header set Cache-Control "max-age=60, must-revalidate"
#</filesMatch>

# 2 DAYS
<filesMatch "\.(xml|txt)$">
ExpiresDefault A172800
Header set Cache-Control "max-age=172800, must-revalidate"
</filesMatch>

# 1 WEEK
<filesMatch "\.(jpe?g|png|gif|swf|js|css)$">
ExpiresDefault A604800
Header set Cache-Control "max-age=604800, must-revalidate"
</filesMatch>

# 1 MONTH
<filesMatch "\.(ico|pdf|flv)$">
ExpiresDefault A2419200
Header set Cache-Control "max-age=2419200, must-revalidate"
</filesMatch>


#mime_module.conf

# ----------------------------------------------------------------------
# Mime Types
# Mime Associates the requested filename's extensions with the file's behavior and content
# http://httpd.apache.org/docs/2.0/mod/mod_mime.html
# ----------------------------------------------------------------------

#<IfModule mod_mime.c>
AddType text/css .css
AddType application/x-javascript .js
AddType text/x-component .htc
AddType text/html .html .htm
AddType text/richtext .rtf .rtx
AddType image/svg+xml .svg .svgz
AddType text/plain .txt
AddType text/xsd .xsd
AddType text/xsl .xsl
AddType text/xml .xml
AddType video/asf .asf .asx .wax .wmv .wmx
AddType video/avi .avi
AddType image/bmp .bmp
AddType application/java .class
AddType video/divx .divx
AddType application/msword .doc .docx
AddType application/vnd.ms-fontobject .eot
AddType application/x-msdownload .exe
AddType image/gif .gif
AddType application/x-gzip .gz .gzip
AddType image/x-icon .ico
AddType image/jpeg .jpg .jpeg .jpe
AddType application/vnd.ms-access .mdb
AddType audio/midi .mid .midi
AddType video/quicktime .mov .qt
AddType audio/mpeg .mp3 .m4a
AddType video/mp4 .mp4 .m4v
AddType video/mpeg .mpeg .mpg .mpe
AddType application/vnd.ms-project .mpp
AddType application/x-font-otf .otf
AddType application/vnd.oasis.opendocument.database .odb
AddType application/vnd.oasis.opendocument.chart .odc
AddType application/vnd.oasis.opendocument.formula .odf
AddType application/vnd.oasis.opendocument.graphics .odg
AddType application/vnd.oasis.opendocument.presentation .odp
AddType application/vnd.oasis.opendocument.spreadsheet .ods
AddType application/vnd.oasis.opendocument.text .odt
AddType audio/ogg .ogg
AddType application/pdf .pdf
AddType image/png .png
AddType application/vnd.ms-powerpoint .pot .pps .ppt .pptx
AddType audio/x-realaudio .ra .ram
AddType application/x-shockwave-flash .swf
AddType application/x-tar .tar
AddType image/tiff .tif .tiff
AddType application/x-font-ttf .ttf .ttc
AddType audio/wav .wav
AddType audio/wma .wma
AddType application/vnd.ms-write .wri
AddType application/vnd.ms-excel .xla .xls .xlsx .xlt .xlw
AddType application/zip .zip
#</IfModule>




#mod_deflate.conf
#LoadModule cache_module modules/mod_cache.so
#LoadModule cache_disk_module modules/mod_cache_disk.so
<IfModule mod_cache_disk.c>
CacheRoot Z:/TMP
CacheEnable disk /

# Cache content before mod_include and mod_deflate
CacheQuickHandler off
AddOutputFilterByType CACHE;INCLUDES;DEFLATE text/html text/plain text/css text/xml text/javascript
</IfModule>



LoadModule headers_module modules/mod_headers.so
LoadModule deflate_module modules/mod_deflate.so




#<IfModule mod_deflate.c>
# Force deflate for mangled headers developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/
# <IfModule mod_setenvif.c>
# <IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
# </IfModule>
# </IfModule>

# <IfModule filter_module>

# HTML, TXT, CSS, JavaScript, JSON, XML, HTC:
# apache 2.4.4 bugfix
FilterDeclare   COMPRESS
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/html'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/css'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/plain'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/xml'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'text/x-component'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/javascript'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/json'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/xml'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/xhtml+xml'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/rss+xml'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/atom+xml'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/vnd.ms-fontobject'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'image/svg+xml'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'image/x-icon'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'application/x-font-ttf'"
FilterProvider  COMPRESS  DEFLATE "%{Content_Type} = 'font/opentype'"
FilterChain     COMPRESS
FilterProtocol  COMPRESS  DEFLATE change=yes;byteranges=no
# </IfModule>

# <IfModule !mod_filter.c>
# # Legacy versions of Apache
# AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
# AddOutputFilterByType DEFLATE application/javascript
# AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
# AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
# AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
# </IfModule>

#</IfModule>



<FilesMatch "(\.(bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
# js 의 cookie 접근을 제한하는 듯?
#<IfModule php5_module>
# php_value session.cookie_httponly true
#</IfModule>

# ----------------------------------------------------------------------
# Webfont access
# Allow access from all domains for webfonts.
# ----------------------------------------------------------------------

#<IfModule mod_headers.c>
<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
#</IfModule>

# ----------------------------------------------------------------------
# Force latest IE rendering engine
# ----------------------------------------------------------------------

#<IfModule mod_headers.c>
Header set X-UA-Compatible "IE=Edge,chrome=1"
# mod_headers can't match by content-type, but we don't want to this header on everything
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
Header unset X-UA-Compatible
</FilesMatch>
#</IfModule>

# ----------------------------------------------------------------------
# Instructs the proxies to cache two versions of the resource: one compressed, and one uncompressed.
# https://developers.google.com/speed/docs/best-practices/caching#LeverageProxyCaching
# ----------------------------------------------------------------------
#<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary: Accept-Encoding
  </FilesMatch>
#</IfModule>

#<IfModule mod_setenvif.c>
# <IfModule mod_headers.c>
<FilesMatch "\.(gif|png|jpe?g|svg|svgz|ico|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
</FilesMatch>
# </IfModule>
#</IfModule>




굿굿!!
The-Perfect-Apache-Configuration.git
가입인사 작성 후 다운로드, 게시글/댓글 등록이 가능합니다.
가입인사 게시판에 작성한 내용은 자기소개글로 자동 등록됩니다.
댓글11

공지사항

번호 제목 글쓴이 날짜 조회
공지 게시판 푸시 알림 / 통합 앱 서비스 31 file 트디개발자 2023.09.20 837.1k
공지 반복적으로 다운로드할 시 포인트가 부족할 수 있습니다. 325 우녕자 2014.12.12 42.4k
공지 맨땅 초보자 가이드 598 file 뮤리아 2020.10.16 995.7k
공지 카카오톡 1:1 채팅방 만드는 법 101 트디개발자 2018.05.20 424.9k
119 검색 데이터를 날렸습니다. 1 우녕자 2014.05.12 3.4k
118 Today's Specials 추가 예정 2 우녕자 2014.05.13 3.0k
117 인기할인 - 아마존/바바리안 아이템 추가. 4 우녕자 2014.06.11 3.4k
116 회원가입 안내 14 우녕자 2014.09.22 3.3k
115 개발 로그 5 우녕자 2014.10.02 2.7k
114 보안 업데이트 5 우녕자 2014.10.15 2.6k
113 래더검색 복구 7 우녕자 2014.10.16 2.7k
112 회원가입 오류 수정 34 우녕자 2014.11.25 2.3k
111 업데이트 오류 수정 11 우녕자 2014.12.04 2.0k
110 다운로드시 게시글이나 댓글쓰기가 요구됩니다. 51 우녕자 2014.12.07 2.2k
109 반복적으로 다운로드할 시 포인트가 부족할 수 있습니다. 325 우녕자 2014.12.12 42.4k
108 데이터베이스 업데이트 - mariadb-10.0.15-winx64 2 우녕자 2014.12.12 1.9k
107 D2NT 37차,38차에서 트로이가 발견되었습니다. 58 우녕자 2014.12.15 4.6k
106 사이트 속도가 느린 원인을 조사중입니다. 16 우녕자 2014.12.18 2.0k
> 웹서버 설정 최적화 11 우녕자 2014.12.22 2.4k
104 업데이트 할일 기록 14 우녕자 2014.12.22 2.0k
103 메일 서버 오류 수정 170 우녕자 2015.01.20 3.6k
102 채팅방이 추가되었습니다. 48 우녕자 2015.02.07 1.9k
101 해싸 검색 속도 개선 78 우녕자 2015.02.10 2.4k
100 실시간 채팅 위한 nodejs 구축 기록 우녕자 2015.04.25 1.6k