posted by 은이종 2017. 8. 11. 14:31

Apache Log에서 특정 문자열만 별도로 분리할 경우가 생겨서

작업 진행해보았다.


httpd.conf 내에

SetEnvIfNoCase Request_URI "/download/temp/pdfexport" customlog2

SetEnvIfNoCase Request_URI "exportword" customlog2

CustomLog "|/app/apache/bin/rotatelogs -l /app/log/apache/export_%Y%m%d.log 86400" combined env=customlog2

설정 추가


access로그에

"/download/temp/pdfexport"

"exportword"

라는 문자열이 있는 Log는 

export_날짜.log 형태로 분리시키는 설정


'Web/WAS > Apache' 카테고리의 다른 글

mod_define  (0) 2016.05.17
Apache conf 표준설정  (0) 2016.04.21
Apache socket_timeout , reply_timeout 설정  (0) 2015.12.30
Apache pagespeed 설치  (0) 2015.03.18
Apache method 설정  (0) 2014.11.25
posted by 은이종 2016. 5. 17. 11:54

 

This module is contained in the mod_define.c file. It provides the definition variables for arbitrary directives, i.e. variables which can be expanded on any(!) directive line. It is compatible with Apache httpd 2.0 and 2.2. It is not compiled into the server by default. To use mod_define you have to enable the following line in the server build Configuration file:

    AddModule  modules/extra/mod_define.o

 

 

http://people.apache.org/~rjung/mod_define/

 

mod_define.c

 


첨부한 파일을 옮긴 후,

 

apxs –i – a –c mod_define.c

으로 설치

 

httpd.conf에

----------------------------------------------------

LoadModule define_module    modules/mod_define.so

--------------------------------------------------

자동으로 기입된다.

 

해당 소켓파일은 /apache/module에 위치하니 확인

'Web/WAS > Apache' 카테고리의 다른 글

Apache Log 2개로 분리하기  (0) 2017.08.11
Apache conf 표준설정  (0) 2016.04.21
Apache socket_timeout , reply_timeout 설정  (0) 2015.12.30
Apache pagespeed 설치  (0) 2015.03.18
Apache method 설정  (0) 2014.11.25
posted by 은이종 2016. 4. 21. 14:16

참고용 Apache conf 표준 설정 내역입니다.

======================================

1. httpd.conf

 


ServerRoot "/app/apache"

Listen 80
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>

User daemon
Group daemon

</IfModule>
</IfModule>

ServerAdmin 메일주소@메일

ServerName localhost
CoreDumpDirectory /app/log/apache/coredump

DocumentRoot "/app/docroot/apache"

#
<Directory />
Options None
AllowOverride None
Order deny,allow
Deny from all
</Directory>

# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/app/docroot/apache">
Options None
AllowOverride None
Order allow,deny
Allow from all

<LimitExcept GET POST>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>

<Directory "/app/apache/cgi-bin">
AllowOverride None
Options None
Order deny,allow
Deny from all
</Directory>

<LocationMatch "/WEB-INF">
Deny from all
</LocationMatch>

<LocationMatch "/META-INF">
Deny from all
</LocationMatch>

<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>

<FilesMatch "^\.ht">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>

LogLevel warn

<IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %D %I %O" combinedio
</IfModule>
</IfModule>

SetEnvIfNoCase User-Agent "Zabbix" do_not_log
SetEnvIfNoCase Request_URI "/wscript.jsp" do_not_log
SetEnvIfNoCase Request_URI "/wscript.php" do_not_log
SetEnvIf Remote_Addr "@@ZABBIX_SERVER@@" do_not_log
#SetEnvIf Remote_Addr "127.0.0.1" do_not_log

ErrorLog "|/app/apache/bin/rotatelogs -l /app/log/apache/error_%Y%m%d.log 86400"
CustomLog "|/app/apache/bin/rotatelogs -l /app/log/apache/access_%Y%m%d.log 86400" combined env=!do_not_log

Alias /errors/ "/app/docroot/apache/errors/"

ErrorDocument 400 "Error"
ErrorDocument 401 "Error"
ErrorDocument 402 "Error"
ErrorDocument 403 "Error"
ErrorDocument 404 "Error"
ErrorDocument 405 "Error"
ErrorDocument 406 "Error"
ErrorDocument 407 "Error"
ErrorDocument 408 "Error"
ErrorDocument 409 "Error"
ErrorDocument 410 "Error"
ErrorDocument 411 "Error"
ErrorDocument 412 "Error"
ErrorDocument 413 "Error"
ErrorDocument 414 "Error"
ErrorDocument 415 "Error"
ErrorDocument 416 "Error"
ErrorDocument 417 "Error"
ErrorDocument 422 "Error"
ErrorDocument 423 "Error"
ErrorDocument 424 "Error"
ErrorDocument 426 "Error"
ErrorDocument 500 "Error"
ErrorDocument 501 "Error"
ErrorDocument 502 "Error"
ErrorDocument 503 "Error"
ErrorDocument 504 "Error"
ErrorDocument 505 "Error"
ErrorDocument 506 "Error"
ErrorDocument 507 "Error"
ErrorDocument 508 "Error"
ErrorDocument 510 "Error"

<IfModule cgid_module>
</IfModule>

DefaultType text/plain

<IfModule mime_module>
TypesConfig conf/mime.types

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

AddType application/x-httpd-php .php .php3 .inc .ph .htm
AddType application/x-httpd-php-source .phps
</IfModule>

FileETag None

<ifmodule mod_expires.c>
<Filesmatch "\.(jpg|jpeg|png|gif|swf)$">
ExpiresActive on
ExpiresDefault "access plus 4 years"
</Filesmatch>

<Filesmatch "\.(vss|js)$">
ExpiresActive on
ExpiresDefault "access plus 1 month"
</Filesmatch>
</ifmodule>

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

DeflateCompressionLevel 9

<Location />
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip

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

SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|jpg|swf)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:xml)$ no-gzip dont-vary

</Location>

# TRACE-TRACK 제거

RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]

# all request ssl rewrite
#RewriteCond %{HTTPS} off
#RewriteCond %{REQUEST_URI} !^/jkmanager/*
#RewriteCond %{REQUEST_URI} !^/server-status*
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

#RewriteEngine on
#RewriteCond %{HTTP_HOST} ^skplanetoneid\.com
#RewriteRule (.*)
https://www.%{HTTP_HOST}%{REQUEST_URI} [R]

UserDir disabled

Include conf/extra/httpd-default.conf
Include conf/extra/httpd-mpm.conf

Include conf/extra/httpd-vhosts.conf

#Include conf/extra/httpd-languages.conf
#Include conf/extra/httpd-ssl.conf

##### Tomcat 연동시 아래설정 주석해재 #####

#LoadModule jk_module modules/mod_jk.so

#<IfModule jk_module>
# JkWorkersFile conf/workers.properties
# JkLogFile "|/app/apache/bin/rotatelogs -l /app/log/apache/mod_jk.%Y%m%d.log 86400"
# JkLogLevel info
# JkShmFile logs/mod_jk.shm
# JkWatchdogInterval 60
# JkOptions +FlushPackets +FlushHeader
#</IfModule>

======================================================

extra/httpd-default.conf

#
Timeout 15
KeepAlive Off
MaxKeepAliveRequests 1000
KeepAliveTimeout 5
UseCanonicalName Off
AccessFileName .htaccess
ServerTokens Prod
ServerSignature Off
HostnameLookups Off
TraceEnable Off

LimitRequestFieldsize 10000
LimitRequestBody 10000000

Include conf/extra/httpd-mpm.conf (활성화)

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>

ServerLimit 8
StartServers 8
MinSpareThreads 124
MaxSpareThreads 372
ThreadsPerChild 62
MaxClients 496
MaxRequestsPerChild 10000

</IfModule>

=================================================================

extra/httpd-vhosts.conf

#NameVirtualHost _default_:80
<VirtualHost _default_:80>
ServerName _default_:80
DocumentRoot /app/docroot/apache/
CustomLog "|/app/apache/bin/rotatelogs -l /app/log/apache/
www.domain.com-access_log-%Y%m%d.log 86400" combined env=!do_not_log
ErrorLog "|/app/apache/bin/rotatelogs -l /app/log/apache/
www.domain.com-error_log-%Y%m%d.log 86400"
JkMount /*.jsp Tomcat
JkMount /*.do Tomcat
</VirtualHost>

==================================================================

extra/httpd-languages.conf (필요시)

#
# Settings for hosting different languages.
#
# Required modules: mod_mime, mod_negotiation

# DefaultLanguage and AddLanguage allows you to specify the language of
# a document. You can then use content negotiation to give a browser a
# file in a language the user can understand.
#
# Specify a default language. This means that all data
# going out without a specific language tag (see below) will
# be marked with this one. You probably do NOT want to set
# this unless you are sure it is correct for all cases.
#
# * It is generally better to not mark a page as
# * being a certain language than marking it with the wrong
# * language!
#
# DefaultLanguage nl
#
# Note 1: The suffix does not have to be the same as the language
# keyword --- those with documents in Polish (whose net-standard
# language code is pl) may wish to use "AddLanguage pl .po" to
# avoid the ambiguity with the common suffix for perl scripts.
#
# Note 2: The example entries below illustrate that in some cases
# the two character 'Language' abbreviation is not identical to
# the two character 'Country' code for its country,
# E.g. 'Danmark/dk' versus 'Danish/da'.
#
# Note 3: In the case of 'ltz' we violate the RFC by using a three char
# specifier. There is 'work in progress' to fix this and get
# the reference data for rfc1766 cleaned up.
#
# Catalan (ca) - Croatian (hr) - Czech (cs) - Danish (da) - Dutch (nl)
# English (en) - Esperanto (eo) - Estonian (et) - French (fr) - German (de)
# Greek-Modern (el) - Hebrew (he) - Italian (it) - Japanese (ja)
# Korean (ko) - Luxembourgeois* (ltz) - Norwegian Nynorsk (nn)
# Norwegian (no) - Polish (pl) - Portugese (pt)
# Brazilian Portuguese (pt-BR) - Russian (ru) - Swedish (sv)
# Turkish (tr) - Simplified Chinese (zh-CN) - Spanish (es)
# Traditional Chinese (zh-TW)
#
AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage da .dk
AddLanguage de .de
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
AddLanguage es .es
AddLanguage et .et
AddLanguage fr .fr
AddLanguage he .he
AddLanguage hr .hr
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ko .ko
AddLanguage ltz .ltz
AddLanguage nl .nl
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
AddLanguage ru .ru
AddLanguage sv .sv
AddLanguage tr .tr
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw

# LanguagePriority allows you to give precedence to some languages
# in case of a tie during content negotiation.
#
# Just list the languages in decreasing order of preference. We have
# more or less alphabetized them here. You probably want to change this.
#
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv tr zh-CN zh-TW

#
# ForceLanguagePriority allows you to serve a result page rather than
# MULTIPLE CHOICES (Prefer) [in case of a tie] or NOT ACCEPTABLE (Fallback)
# [in case no accepted languages matched the available variants]
#
ForceLanguagePriority Prefer Fallback

#
# Commonly used filename extensions to character sets. You probably
# want to avoid clashes with the language extensions, unless you
# are good at carefully testing your setup after each change.
# See
http://www.iana.org/assignments/character-sets for the
# official list of charset names and their respective RFCs.
#
AddCharset us-ascii.ascii .us-ascii
AddCharset ISO-8859-1 .iso8859-1 .latin1
AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen
AddCharset ISO-8859-3 .iso8859-3 .latin3
AddCharset ISO-8859-4 .iso8859-4 .latin4
AddCharset ISO-8859-5 .iso8859-5 .cyr .iso-ru
AddCharset ISO-8859-6 .iso8859-6 .arb .arabic
AddCharset ISO-8859-7 .iso8859-7 .grk .greek
AddCharset ISO-8859-8 .iso8859-8 .heb .hebrew
AddCharset ISO-8859-9 .iso8859-9 .latin5 .trk
AddCharset ISO-8859-10 .iso8859-10 .latin6
AddCharset ISO-8859-13 .iso8859-13
AddCharset ISO-8859-14 .iso8859-14 .latin8
AddCharset ISO-8859-15 .iso8859-15 .latin9
AddCharset ISO-8859-16 .iso8859-16 .latin10
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5.Big5 .big5 .b5
AddCharset cn-Big5 .cn-big5
# For russian, more than one charset is used (depends on client, mostly):
AddCharset WINDOWS-1251 .cp-1251 .win-1251
AddCharset CP866 .cp866
AddCharset KOI8 .koi8
AddCharset KOI8-E .koi8-e
AddCharset KOI8-r .koi8-r .koi8-ru
AddCharset KOI8-U .koi8-u
AddCharset KOI8-ru .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-7 .utf7
AddCharset UTF-8 .utf8
AddCharset UTF-16 .utf16
AddCharset UTF-16BE .utf16be
AddCharset UTF-16LE .utf16le
AddCharset UTF-32 .utf32
AddCharset UTF-32BE .utf32be
AddCharset UTF-32LE .utf32le
AddCharset euc-cn .euc-cn
AddCharset euc-gb .euc-gb
AddCharset euc-jp .euc-jp
AddCharset euc-kr .euc-kr
#Not sure how euc-tw got in - IANA doesn't list it???
AddCharset EUC-TW .euc-tw
AddCharset gb2312 .gb2312 .gb
AddCharset iso-10646-ucs-2 .ucs-2 .iso-10646-ucs-2
AddCharset iso-10646-ucs-4 .ucs-4 .iso-10646-ucs-4
AddCharset shift_jis .shift_jis .sjis

===============================================

extra/httpd-ssl.conf

#
Listen 443

AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl

SSLPassPhraseDialog builtin
#SSLPassPhraseDialog
exec:/app/apache/conf/sslkey/pass.sh
SSLSessionCache "shmcb:/app/apache/logs/ssl_scache(512000)"
SSLSessionCacheTimeout 300
SSLMutex "
file:/app/apache/logs/ssl_mutex"

################################################
#Redirect 404 /favicon.ico
#<Location /favicon.ico>
# ErrorDocument 404 "No favicon"
#</Location>
#
#SetEnvIf Request_URI "favicon.ico" do_not_log

#NameVirtualhost *:443

<VirtualHost _default_:443>

# General setup for the virtual host
DocumentRoot "/app/docroot/apache"
ServerName _default_:443
ServerAdmin 메일주소@메일

# default single domain
CustomLog "|/app/apache/bin/rotatelogs -l /app/log/apache/ssl_access_log-%Y%m%d.log 86400" combined env=!do_not_log
ErrorLog "|/app/apache/bin/rotatelogs -l /app/log/apache/ssl_error_log-%Y%m%d.log 86400"
CustomLog "|/app/apache/bin/rotatelogs -l /app/log/apache/ssl_request_log.%Y%m%d 86400" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" env=!do_not_log

# for multi domain
#CustomLog "|/app/apache/bin/rotatelogs -l /app/log/apache/
www.domain.com-ssl_access_log-%Y%m%d.log 86400" combined env=!do_not_log
#ErrorLog "|/app/apache/bin/rotatelogs -l /app/log/apache/
www.domain.com-ssl_error_log-%Y%m%d.log 86400"
#CustomLog "|/app/apache/bin/rotatelogs -l /app/log/apache/
www.domain.com-ssl_request_log.%Y%m%d 86400" \
# "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" env=!do_not_log

JkMount /*.jsp Tomcat
JkMount /*.do Tomcat

SSLEngine on
SSLProtocol ALL -SSLv2
SSLHonorCipherOrder on
SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:RC4-SHA:RC4-MD5:AES256-SHA256:AES128-SHA256:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!SSLv2

SSLCertificateFile        "인증서"
SSLCertificateKeyFile    "인증서
"
SSLCertificateChainFile "인증서
"
SSLCACertificateFile    "인증서
"

<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/app/apache/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
</VirtualHost>

'Web/WAS > Apache' 카테고리의 다른 글

Apache Log 2개로 분리하기  (0) 2017.08.11
mod_define  (0) 2016.05.17
Apache socket_timeout , reply_timeout 설정  (0) 2015.12.30
Apache pagespeed 설치  (0) 2015.03.18
Apache method 설정  (0) 2014.11.25
posted by 은이종 2015. 12. 30. 17:05

 

socket_timeout & reply_timeout ERROR CODE

· - socket_timeout 발생시, access log에 502(Bad GateWay)이 발생.

· - reply_timeout 발생 시 access log에 504(Gateway Time-out) 이 발생.

 

mod_jk(worker.properties) 의 socket_timeout 옵션

ex) socket_timeout 을 10초로 설정

worker.worker1.socket_timeout=10
worker.worker1. retries=1


◾클라이언트 요청 이후 10초 이상 응답이 지연되면 클라이언트로 502 리턴 (retries 설정 1 기준)
◾비정상 응답이라 하더라도 클라이언트에게 빠르게 응답을 줄 수 있고, 클라이언트<->웹서버 부하에 대한 timeout 컨트롤을 할 수 있다.
◾다만 WAS의 부하와는 무관한 설정으로, WAS 행업에는 도움이 되지 않는다.


'Web/WAS > Apache' 카테고리의 다른 글

mod_define  (0) 2016.05.17
Apache conf 표준설정  (0) 2016.04.21
Apache pagespeed 설치  (0) 2015.03.18
Apache method 설정  (0) 2014.11.25
Apache 멀티 Redirect시 주의점  (0) 2014.11.05
posted by 은이종 2015. 3. 18. 11:21

웹페이지 가속 기술중에 하나인 pagespeed

기본적으로는 사이트 속도를 개선하기 위해서 페이지 로딩 타임을 줄이고 이를 바탕으로 페이지의 호출 시간과 네트워크 대역폭의 최적화해서 속도를 개선하는 쪽에 방점을 가지고 있는 모양이다.

이런 세부적인 기술적인 요인들을 하나의 결과물로 만들어  아파치 웹서버 모듈의 일종으로 규합한 것이다. 일단, 개발자 블로그에 올라온 내용에 따르면 현재 콘텐츠 및 워크로드 수정 없이 CSS, 자바스크립트, 이미지를 건들이지 않고 성능 개선할 수 있다고 한다

- 설치 -

1. at 패키지 확인. 없으면 설치

yum install at

 

2. mod_pagespeed 땡겨오기

wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm

 

3. 설치

설치할 곳으로 이동

cd /root/job/mod_pagespeed

rpm2cpio mod-pagespeed-stable_current_x86_64.rpm | cpio -idmv

 

4. socket 복사

- apache 2.2.X
cp /root/job/usr/lib64/httpd/module/mod_pagespeed.so /app/apache/modules/
- apache 2.4.X
cp /root/job/mod_pagespeed/usr/lib64/httpd/modules/mod_pagespeed_ap24.so /app/apache/modules/

- 설정파일 copy
cp /root/job/mod_pagespeed/etc/httpd/conf.d/pagespeed.conf  /app/apache/conf/

cp /root/job/mod_pagespeed/etc/httpd/conf.d/pagespeed_libraries.conf /app/apache/conf/

-복사한 파일들의 소유권 및 소유자 변경

mkdir /app/pagespeed

mkdir /app/pagespeed/bin

mkdir /app/pagespeed/cache 
mkdir /app/pagespeed/files

cp /root/job/mod_pagespeed/usr/bin/pagespeed_js_minify /app/pagespeed/bin

chown -R daemon.daemon /app/pagespeed

chown -R daemon.daemon /app/apache/conf/pagespeed*.conf

chown -R daemon.daemon /app/apache/modules/mod_pagespeed*

chmod 660 /app/apache/modules/mod_pagespeed*

 

5. 환경설정

가. httpd.conf Include 설정

vi httpd.coonf에 추가

==========================

Include pagespeed.conf

=========================

나. Load 추가 설정

vi /app/apache/conf/pagespeed.conf

----------------------------------------------------------------------------------------------

LoadModule pagespeed_module modules/mod_pagespeed.so

----------------------------------------------------------------------------------------------

 

6. 테스트 방법

PageSpeed는 두 가지 방법으로 실행할 수 있다.

첫 번째는 https://developers.google.com/speed/pagespeed/insights/에 들아가서 URL을 입력하는 방법이다.

두 번째는 크롬 플러그인을 설치해서 크롬에서 '요소검사' 화면에 들어가서 보는 방법이다. 특히, 크롬에서는 아직 공개된 URL로 들어갈 수 없는 로컬 프로그램이나 회사 내부 프로그램까지 돌려볼 수 있다. 크롬은 역시나 개발을 위한 브라우저이다.

실행결과는 모바일과 PC 버전으로 각각 보여주고, 결과를 3가지 수준(Red, Yellow, Green)으로 나눠서 보여준다. 그리고 결과를 종합해 100점 만점으로 점수를 내준다. 정확한 '의미'를 부여하기는 어렵지만 재밌는 수치이다.

posted by 은이종 2014. 11. 25. 17:13

Method 정의

================================================================================================
HTTP/1.1에서 사용되는 일반적인 method 세트를 아래에 규정하였다. 이 세트를 확장할 수 있지만
추가된 method를 별도로 확장된 클라이언트와 서버가 동일한 의미를 공유하고 있다고 가정할 수 없다.
호스트 Request-Header 필드(14.23 절)는 반드시 모든 HTTP/1.1 요구를 따라야 한다.

GET - 지정된 URL 정보를 요청한다.(이때 전달해야 하는 파라메터를 URL에 포함시켜서 전달한다.)

POST - 지정된 URL 정보를 요청한다. (이때 전달해야 하는 파라메터를 메시지 본문(Request Message Body)을 통해서 전달한다.)

HEAD - HTTP Header 정보만 요청한다.

TRACE - 클라이언트의 요청을 그대로 응답한다. (Request의 Loop Back 테스트)

DELETE - 요청하는 URL의 자원을 삭제한다.

OPTIONS - 응답 가능한(서버에서 지원하는) HTTP 메소드를 요청

PUT - 요청하는 URL의 자원을 생성한다.   예를 들면  파일 업로드가 가능하다.

CONNECT - 터널링의 목적으로 연결 요청

** HTTP 버전별 지원 Method **

HTTP/0.9 - GET

HTTP/1.0 - GET, POST, HEAD

HTTP/1.1 - GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE, CONNECT

# 아파치는 서버 전체에는 옵션을 줄 수 없습니다. 해당 디렉터리 별로 각각 설정하셔야 합니다.

1.

<Directory /home>

    <Limit PUT DELETE OPTIONS>
        Order allow,deny
        Allow from all

      </Limit>

</Directory>

또는

2.

<Directory /home>

    <LimitExcept GET POST>

    Order deny,allow
    Deny from all
    </LimitExcept>

</Directory>

두 가지 방법 중 편한 걸로 사용하면 된다.

다 열고 특정 Method를 설정하거나 (PUT, DELETE, OPTIONS)

다 막고 허용할Method를 설정하거나, (GET, POST)



=============================================


Web-WAS 구조이면

WAS쪽도 같이 진행해줘야 한다.



 

posted by 은이종 2014. 11. 5. 19:03



 

 mod_rewrite 모듈을 이용한 특정 페이지 redirect

1. 
 RewriteEngine On
 RewriteCond %{HTTPS} off
 RewriteRule ^/user/login(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R, L]
 
사용한 변수들)

 RewriteEngine: rewrite 모듈의 사용 여부 [On/Off]
 RewriteCond: rewrite 실행할 조건
 RewriteRule: 조건이 만족할 경우 실제로 rewrite가 일어날 원본 주소와 rewrite 된 주소
 
%{HTTPS} : SSL 사용 여부 [on/off] - mod_ssl 필요
 %{HTTP_HOST} : 호출된 서버의 domain. 포트 번호 있을 경우에는 port 번호 포함.
   ex) http://www.gmate.co.kr/myurl.html?var=value => www.gmate.com.kr
 %{REQUEST_URI} : 도메인 이후의 리소스 절대 경로 및 파라미터
   ex) http://www.gmate.co.kr/myurl.html?var=value => /myurl.html?var=value
 [R] : 강제로 redirect 시킴 (http status code에 따라 분기할 수 있습니다.)
 [L] : 마지막 RewriteRule 표시. (이후의 RewriteRule은 무시됨)

2. 
다중 Apache Port를 Redirect 시, 302 에러 발생할때 체크사항

1대의 서버에, 
80, 81 port 처럼 다중으로 사용시, 각각 443,444로 Redirect시 

SERVER IP = 123.123.123.123 일때, 81port를 444Port로 Redirect할때

 RewriteCond (.*) https://%{HTTP_HOST}:444%{REQUEST_URI}
으로 설정할 경우
123.123.123.123:81  처럼 :81가 붙어서 표시가 되면 제대로 Redirect가 안될경우가 있다.

기존에 사용하던 HTTP_HOST말고 SERVER_NAME으로 바꿔 사용하면


 RewriteCond (.*) https://%{SERVER_NAME}:444%{REQUEST_URI}


으로 정상적으로 진행된다.

참고 )




=============================================

설정시 정확한 log 파악을 위해서

Rewritelog "/경로"
Rewriteloglevel 3
처럼 log설정해서 정확한 오류가 무엇인지 확인하면서 진행하길 추천한다.


 

posted by 은이종 2014. 7. 8. 19:22


ssl 설정시 아파치를 가동하면 비밀번호를 묻게 된다.
비밀번호 입력없이 실행되게 하기 위해서는 비밀번호를 파일로 생성후 파일을 읽어들여 구동되도록 변경한다.

# 비밀번호 파일 생성
[root@localhost home]# vi /usr/local/apache/conf/ssl/passwd.sh

#!/bin/sh
echo "비밀번호"


chmod 700 /usr/local/apache/conf/ssl/passwd.sh

위와 같이 입력후 httpd.conf 파일을 수정한다.

# httpd.conf 파일 수정 (혹은 extra/httpd-ssl.conf)
[root@localhost home]# vi /usr/local/apache/conf/httpd.conf

<IfModule mod_ssl.c>
..
..
# SSLPassPhraseDialog  builtin
SSLPassPhraseDialog  exec:/usr/local/apache/conf/ssl/passwd.sh
</ifModule>

httpd.conf 파일 내용중
SSLPassPhraseDialog builtin을 위에서 저장한 비밀번호 파일 경로로 변경한다.
SSLPassPhraseDialog exec:/usr/local/apache/conf/ssl/passwd.sh


변경 완료후.. 아파치 실행 테스트
/usr/local/apache/bin/apachect1 startssl


1. apache 비밀번호를 파일로 생성
2. apache 구동시 비밀번호를 파일에서 입력되도록 변경
3. apache 실행 확인.

최근 이슈가 되고있는 Openssl 업데이트 후에는 apache 재구동해야하는데
보통 사용하고있는 apachectl graceful로는 적용이 안되니, 필히 stop / start 로 재구동해야한다
 


SSL 인증서 멀티 패스워드 입력 방법

) 패스워드 스크립트 파일을 pass.sh 라고 설정했을시 해당 파일을 열어서 편집

vi pass.sh

  www.aaa.com:      443)          echo "aaaaa";;  

   도메인 부분       포트부분      패스워드 부분


+20170308 추가분

현재 Apache 2.2 버전 이상부터는 SNI지원으로
443 Port 1개에 2개이상의 도메인이 가능한 상황
그래서



등의 형태도 가능하니 꼭 설정할때 httpd-ssl.conf Port 확인



Copy&Paste 용

#!/bin.sh
case $1 in
 www.aaa.com:443) echo "aaaaa";;
 www.bbb.com:444) echo "bbbbb";;
esac

exit0

==================================================================================== 

#!/bin.sh
case $1 in
 www.aaa.com:443) echo "aaaaa";;
 www.bbb.com:443) echo "bbbbb";;
esac

exit0
====================================================================================


Nginx SSL 설정

nginx.conf
-------------------------------------------------------
  server {

        listen 443;
        server_name ur.domain.name;

        ssl on;
        ssl_certificate /etc/nginx/ssl/ur_domain_name.crt.cat;
        ssl_certificate_key /etc/nginx/ssl/ur_domain_name.key;

        location / {
            root /var/www/html;
        }
    }

 ---------------------------------------------------------

 참고로
Nginx 는 Apache와 다르게 SSLPassPhraseDialg 기능이 없다
비밀번호 자동입력은 불가능하고 방법은

아래처럼 인증서 비밀번호 자체를 제거해야한다.
(Private 인증서나, 상용 인증서 둘 다 가능)

cp ur_domain_name.key ur_domain_name.key.bak

openssl rsa -in  ur_domain_name.key.bak -out ur_domain_name.key

 


 

'Web/WAS > Apache' 카테고리의 다른 글

Apache socket_timeout , reply_timeout 설정  (0) 2015.12.30
Apache pagespeed 설치  (0) 2015.03.18
Apache method 설정  (0) 2014.11.25
Apache 멀티 Redirect시 주의점  (0) 2014.11.05
apache 재시작 스크립트  (0) 2013.05.24
posted by 은이종 2013. 5. 24. 15:56
간단하게 http stop 후 start하는 스크립트
start 후 http 데몬이 0인지 체크해서, 다시 시작하는 설정

내용상의 
/app/apache/bin/startHttpd.sh는
apachectl start가 포함되어있는 스크립트이다
(apache 데몬 소유 권한떄문에 스크립트를 만들어서 구동)

---------------------------------------------------------
#!/bin/bash
date

DAEMON=http
COUNT=$(ps acx | grep -c $DAEMON)

/app/apache/bin/startHttpd.sh stop

while [ 1 ]
do
COUNT=$(ps acx | grep -c $DAEMON)
if [ "$COUNT" -ne "0" ]; then
echo $COUNT
sleep 1
else
break;
fi
done

/app/apache/bin/startHttpd.sh
sleep 1

COUNT=$(ps acx | grep -c $DAEMON)
### http daemon check ###
if [ "$COUNT" -eq "0" ]; then
echo "$DAEMON is no running. "
echo "$DAEMON is re-start."
/app/apache/bin/startHttpd.sh
fi

echo "Apache restart done!"

-----------------------------------------------------


/app/apache/bin/startHttpd.sh