2016년 9월 28일 수요일

[Java] SSLHandshakeException 처리 방안


javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target​

SSLHandshakeException 은 https 통신시 인증서 없이 통신할 경우 발생한다고 하는데,
해결 방법은 구글링을 통해 알아본 결과 java keystore 에 인증서를 추가하는 방법이 있다.

1. 첨부 파일을 다운 받고(따로 폴더를 만들어도 된다.) InstallCert.java 로 rename 한다.
2. javac InstallCert.java
3. java -cp ./ InstallCert yourdomain:port
4. 1을 치고 엔터를 눌러 인증서 저장 (jssecacerts 파일이 생성된다) 이 부분은 스크린샷을 넣고 싶으나 생략하고, 참고사이트 2번째를 방문해서 봐주세요.
5. sudo cp jssecacerts "{$JAVA_HOME}"/jre/lib/security/​  : ("{$JAVA_HOME}" 은 환경변수의 값을 넣으면 된다.
6. 3번을 똑같이 치면 ( java -cp ./ InstallCert yourdomain:port )​ 처음과 다르게 성공적으로 접속했다고 뜨면 완료된 것이다.

-----------------------------------------------------------------------------------
[rainn@~/InstallCert] $ java -cp ./ InstallCert ldap.yourcompany.com:636
Loading KeyStore jssecacerts...
Opening connection to ldap.yourcompany.com:636...
Starting SSL handshake...
No errors, certificate is already trusted
Server sent 1 certificate(s):

 1 Subject
   Issuer  CN=yourcompany, DC=yourcompany, DC=com
   sha1    3e b9 5b 42 57 90 55 49 31 e8 98 9e 5c d7 e7 d5 ad 40 5f 17
   md5     50 79 80 d5 29 cd 69 f4 50 74 84 54 2b 4e 1c 3a

Enter certificate to add to trusted keystore or 'q' to quit: [1]

q

KeyStore not changed
------------------------------------------------------------------------------------


참고 사이트

http://knight76.tistory.com/1930 (SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed / java.lang.UnsupportedOperationException at InstallCert$SavingTrustManager.getAcceptedIssuers (installcert.java))
http://lesstif.com/pages/viewpage.action?pageId=12451848​ (Java 의 keystore에 SSL Server 인증서를 import 하는 방법​)​
http://tskwon.tistory.com/323 (MAC 에서 JAVA_HOME 경로 확인)

[Scouter] 설치


Setup
Scouter do not require any installation except java.

---------------------------------------------
1. Server

Prerequisite : JDK 1.6+


Start Server
 (1) Download scouter-yyyyMMdd.tar.gz - Release Page
 (2) Extract /server directory and copy ${SCOUTER_SERVER_DIR}
 (3) Execute startup.sh(You can modify JVM Options in this file)
 (4) Done
  ____                  _
 / ___|  ___ ___  _   _| |_ ___ _ __
 \___ \ / __/   \| | | | __/ _ \ '__|
  ___) | (_| (+) | |_| | ||  __/ |
 |____/ \___\___/ \__,_|\__\___|_|
 Scouter version 0.0.1 20150602
 Open Source Performance Monitoring
 System JRE version : 1.7.0_51


Network Port
 These ports can be changed in configuration file.
 UDP Receive Port : 6100
 TCP Service Port : 6100


Configuration

Configuration file

You can configure server options by Adding or modifying(if exist) server/conf/scouter.conf

If no options, all default value will be applied.
Example

conf/scouter.conf

# Agent Control and Service Port(Default : TCP 6100)
net_tcp_listen_port=6100

# UDP Receive Port(Default : 6100)
net_udp_listen_port=6100

# DB directory(Default : ./database)
db_dir=./database

# Log directory(Default : ./logs)
log_dir=./logs
For more options, refer Options page(Coming soon).

--------


2. Tomcat Agent


Prerequisite :
  JDK 1.5+(Required), 1.6+(Recommended)
  Tomcat 6 or 7


Start Tomcat with Scouter agent
 (1) Download scouter-yyyyMMdd.tar.gz - Release Page
 (2) Extract /agent/scouter.agent.jar and copy this file to ${SCOUTER_AGENT_DIR}
 (3) Append Tomcat java options. Refer Java Options
 (4) ${TOMCAT_DIR}/bin/startup.sh
 (5) Done - You can see Scouter logo in catalina log.


Java Options

Append below options in ${TOMCAT_DIR}/bin/catalina.sh or startup.sh

 JAVA_OPTS=" ${JAVA_OPTS} -javaagent:${SCOUTER_AGENT_DIR}/scouter.agent.jar"
 JAVA_OPTS=" ${JAVA_OPTS} -Dscouter.config=${SCOUTER_AGENT_DIR}/scouter.conf"


Configuration

Configuration file

You can configure agent options by modifying ${SCOUTER_AGENT_DIR}/scouter.conf

If no options, all default value will be applied.
Example

${appropriate_directory}/scouter.conf

# Scouter Server IP Address (Default : 127.0.0.1)
net_collector_ip=127.0.0.1

# Scouter Server Port (Default : 6100)
net_collector_udp_port=6100
net_collector_tcp_port=6100

# Scouter Name(Default : tomcat1)
obj_name=tomcat1
For more options, refer Options page(Coming soon).

--------

3. Client

Prerequisite : JRE 1.6+

Start Client
 (1) Download suitable one of scouter.client.product - Release Page
 (2) Extract all files to new directory
 (3) Execute scouter.exe(windows), scouter.app(osx) or scouter(linux)
 (4) You will see a dialog
 (5) Fill the authentication info and press OK button(If server is running)
 (6) The real-time chart will be shown.


Example authentication info

Server Address : 127.0.0.1:6100
ID : admin
password : admin

[Apache] 로드밸런싱 로그 출력


결론부터 말하자면 %{BALANCER_WORKER_NAME}e 항목으로 출력합니다.
예를들면 ajp://web01:8009 와 같이 출력되는데 아래와 같이 httpd.conf에서 설정할 수 있습니다.

######################################################################################################
LogFormat "%h %l %u %t %{BALANCER_WORKER_NAME}e \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
######################################################################################################

설정항목의 자세한 내용은 https://httpd.apache.org/docs/2.2/ja/mod/mod_log_config.html 를 참조하세요.

로드밸런스의 설정은 대략 아래와 같습니다.

######################################################################################################
    <Location />
        Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
        ProxyPass balancer://lb01/ stickysession=ROUTEID|jsessionid nofailover=Off scolonpathdelim=On lbmethod=byrequests
    </Location>

    <Proxy balancer://lb01/>
        BalancerMember ajp://web01:8009 loadfactor=10 route=jvm1 retry=3
        BalancerMember ajp://web02:8009 loadfactor=10 route=jvm2 retry=3
    </Proxy>
######################################################################################################

물론 tomcat이나 jboss쪽의 server.xml 에는 jvmRoute를 꼭 설정하여야 합니다.

위에서 scolonpathdelim=On 이란 url;jsessionid=xxx 와 같이 쿠키를 사용할 수 없는 브라우져에서 url에 세션ID가 포함되는데 이것을 인지하기 위해 설정을 on 으로 합니다.
보통은 쿠키의 ROUTEID란 항목에 어느 루트로 로드밸런싱을 하는지 설정하는데 쿠키를 사용할 수 없을때는 jsessionid 를 이용하게 됩니다.
따라서 stickysession=ROUTEID|jsessionid 로 설정을 해야 합니다.

이렇게 하고 로그 파일에 %{BALANCER_WORKER_NAME}e 항목을 출력하면 해당 요청이 어느 서버로 갔는지 알 수 있습니다.

참고로 http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html 에서는 아래와 같이 항목을 설명하고 있습니다.

BALANCER_SESSION_STICKY
: 현재 Request에 사용되는 stickysession 항목값입니다. ROUTEID인지 jsessionid인지.
BALANCER_SESSION_ROUTE
: 현재 Request를 Parsing하여 얻어진 루트 경로입니다. 즉, 이미 사용되어지고 있는 당신의 세션에 저장된 루트값이며 계속 이쪽 경로로 보내지게 됩니다.
처음 요청시에는 아직 저장된 값이 없기 때문에 null 상태가 됩니다.
BALANCER_WORKER_ROUTE
: 현재 Request가 사용하는 Worker의 루트 경로입니다.
BALANCER_ROUTE_CHANGED
: BALANCER_SESSION_ROUTE값과 BALANCER_WORKER_ROUTE값이 다를경우에 true가 됩니다. 정상적인 경우라면 첫 요청시에 true 를 파악하여 Header add Set-Cookie “ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/” env=BALANCER_ROUTE_CHANGED 의 설정과 같이 쿠키를 추가한후 다음부터는 BALANCER_SESSION_ROUTE에 값이 저장되도록합니다.
BALANCER_NAME
: 현재 Request가 사용하는 로드밸런서이름입니다. balancer://lb01/ 와 같은 값입니다.
BALANCER_WORKER_NAME
: 현재 Request가 사용하는 Workder이름입니다.

[Tomcat] 버전 노출 방지 설정


Apache나, Tomcat 같은 웹서버나, WAS 서버를 공개 소프트웨어를 사용하게 되면 돈이 절약 됩니다.

하지만, 오픈소스 확산에 걸림돌로 작용하는 보안 패치문제는 걱정이 됩니다.

오픈 소스 패키지의 특정 버젼에서 버그를 일으키는 현상을 해커가 알고 있다면 그 홀(구멍)을 통해서 해킹을 할 수도 있습니다.

그래서 오늘은 Java로 웹 서비스할때 많이 쓰이는 apache Tomcat이 오류를 내보낼때 Tomcat의 버젼을 내보지 않도록 하는 설정에 대해서 말씀 드리겠습니다.

톰캣에서 오류를 일으켜 보면 아래와 같은 화면을 만날 수 있습니다.



위 화면에서는 Tomcat의 버젼이 표시 되어 있습니다.

따라서 해당 버젼의 보안 취약점을 이용해서 공격이 들어 올 수도 있겠죠 ^^;;

1차적으로 브라우져를 통해서가지 아니고 curl 같은 툴을 통해서 확인 하는 부분 부터 해결 책을 알아 보면

<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" useBodyEncodingForURI="true"
URIEncoding="UTF-8"
server="apache" />

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" server="apache" />


위 문서 처럼 Connector 태그를 찾아서 server="apache" 라 써 주시면 됩니다.

curl -i 도메인 주소:포트 하시면

apache만 나오는 것을 보실 수 있을 것입니다.

그리고 웹에서의 해결책은

cd [톰캣 설치 위치]/lib/org/apache/catalina/util

vi ServerInfo.properties
열어 보시면 아래와 같이 되어 있을 겁니다.
Server.info=Apache Tomcat/톰캣 버젼
server.number=톰캣 버젼
server.built=빌드 날짜

아래와 비슷하게 수정하시면 됩니다.
server.info=Apache Tomcat
server.number=
server.built=
그리고, 저파일이 저위치에 없을 경우에는

cd [톰캣 설치 위치]/lib/

하시면

catalina.jar 파일이 있습니다.

이파일을 압축을 푸시면 해당 폴더가 생깁니다.

jar xf catalina.jar

그리고 압축을 해제한 jar 파일은 다른곳에 백업해 두십시오.

mv catalina.jar ../catalina.jar.bak

그리고 해당 위치에 가셔서 다시 저 작업을 수행한 후에

톰캣을 재실행하시면 됩니다.

그리고 다시 동일한 오류를 일으켜 보시면



위와 같이 보이시면 해결 된 것입니다. ^^;;

감사합니다.

[Apache] 버전 노출 방지 설정

httpd.conf

 ServerSignature Off
 ServerTokens Prod

[Apache] 컴파일 설치

아파치 2.4 설치


1. 필수 OS 패키지 설치
yum install gcc-c++
yum install openssh-server openssh-clients openssh-askpass
yum install openssl
yum install openssl-devel
yum install zlib-devel

2. pcre 설치
wget http://downloads.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.bz2
./configure --prefix=/usr/local/pcre
make
make install

3. apr 및 apr-util 위치 시키기
wget http://ftp.neowiz.com/apache/apr/apr-1.5.2.tar.bz2
wget http://ftp.neowiz.com/apache/apr/apr-util-1.5.4.tar.bz2
tar xvf apr-1.5.2.tar.bz2
tar xvf apr-util-1.5.4.tar.bz2
mv apr-1.5.2 /아파치설치미지/srclib/apr
mv apr-util-1.5.4 /아파치설치미지/srclib/apr-util

4. apache 설치
 ./configure --prefix=/applications/httpd-2.4.12 --with-included-apr --with-mpm=worker --enable-rewrite=shared --enable-ssl=shared --with-ssl=/usr/bin/openssl --enable-cache=shared --enable-disk-cache=shared --enable-mem-cache=shared --enable-proxy --enable-unique-id --enable-asis=shared --enable-headers --enable-logio=shared --enable-expires=shared --enable-status=shared --enable-auth-digest --enable-deflate=shared --enable-so --with-pcre=/usr/local/pcre

./configure \
--prefix=/applications/httpd-2.4.23 \
--enable-modules=all \
--enable-mods-shared=most \
--with-mpm=worker \
--enable-proxy \
--enable-proxy_http \
--enable-proxy_ajp \
--enable-proxy_connect \
--enable-proxy_express \
--enable-deflate \
--enable-cache \
--enable-mem-cache \
--enable-disk-cache \
--with-ssl=/usr/bin/openssl \
--enable-ssl \
--with-apr=/usr/local/apr \
--with-pcre=/usr/local/pcre
 make
 make install


# 아파치 2.2 설치
 ./configure --prefix=/applications/httpd-2.2.29 --enable-so --enable-modules=all --enable-mods-shared=all --with-mpm=worker --enable-proxy --enable-proxy_http --enable-proxy_connect --enable-cache --enable-mem-cache --enable-disk-cache --enable-deflate --with-ssl=/usr/bin/openssl --enable-ssl
 make
 make install
==========================================================
http://zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_%EC%95%84%ED%8C%8C%EC%B9%98_%EC%B5%9C%EC%8B%A0%EB%B2%84%EC%A0%84_%EC%84%A4%EC%B9%98_(%EC%BB%B4%ED%8C%8C%EC%9D%BC)

[Nginx] 기본 보안 설정

Nginx 기본적인 보안 설정

Nginx 또는 Apach등의 웹서버와 php 등의 개발 언어에는 몇가지 보안관련 설정을 해주는것이 좋다. 주로 HTTP header에서 노출되는 정보값들의 노출 제한 관련된 내용이다.
그중에서 Nginx에 적용할 수 있는 몇가지 설정이다.

1. Nginx 버전 노출 제한

#nginx.conf
http{
 ...
 server_tokens off;
 ...
}

2. X-Powered-By, X-Pingback, X-Link 노출 제한
X-Powered-By은 어떠한 언어로 개발되어 있는지를 보여주는 header 값이다. (ex, X-Powered-By: PHP/5.4.0)
X-Pingback은 http 프로토콜에서 xml 데이터를 전송하기위해 사용되는데, 특별한 용도가 없다면 막아두는것이 좋다.
X-link도 xml 관련된 W3c 표준이긴한데, 특별한 용도가 없다면 막아두는것이 좋다.
(X-Pingback, X-link은 어떻게 쓰이는지 잘 모른다…)

#nginx.conf
http{
 ...
 fastcgi_hide_header X-Powered-By;
 fastcgi_hide_header X-Pingback;
 fastcgi_hide_header Link;

 proxy_hide_header X-Powered-By;
 proxy_hide_header X-Pingback;
 proxy_hide_header X-Link;
 ...
}

정상적으로 설정이 제한되었는지를 확인하기 위해서는 curl 또는 크롬의 개발자도구에서 확인할 수 있다.
curl -I http://사이트주소

[Nginx] 컴파일 설치/구성

출처 : http://blog.naver.com/lov2your/220133550762

 NginX 설치전 준비사항      
       
  pcre 라이브러리 설치      
  # yum install pcre*      
       
  gzip 압축을 사용하기 위해서 설치      
  # yum install zlib zlib-devel      
       
  open ssl 설치      
  # yum iunstall openssl openssl-devel      
       
       
 NginX 다운 및 설치      
       
  NginX 다운받을 폴더로 이동      
  # cd /usr/local/src      
       
  NginX 다운로드      
  # wget http://nginx.org/download/nginx-1.6.2.tar.gz      
       
  다운받은 NginX 파일 압축풀기      
  # tar zxf nginx-1.6.2.tar.gz      
       
  압축을 푼 폴더로 이동      
  # cd nginx-1.6.2      
       
  NginX 폴더안에 있는 내용 컴파일      
  # ./configure --prefix=/usr/local/nginx-1.6.2 --user=daemon --group=daemon --with-http_realip_module --with-http_stub_status_module
  [ex] ./configure --prefix=/applications/nginx-1.9.15 --user=service --group=wheel --with-http_realip_module --with-http_stub_status_module  --with-http_ssl_module  --with-http_sub_module          
   컴파일 옵션 설명    
   --prefix=경로    //컴파일후 설치되는 경로    
   --user=사용자계정   //엔진엑스 작업자 프로세스를 실행하기 위한 기본 사용자 계정 (이설정은 환경설정 파일에 user 지시어를 생략했을 경우에만 적용된다.)    
   --group=그룹   //엔진엑스 작업자 프로세스를 실행하기 위한 기본 사용자 그룹 (이설정은 환경설정 파일에 group 지시어를 생략했을 경우에만 적용된다.)    
   --width-http_realip_module   // 요청 헤데 데이터로부터 실제 IP 주소를 읽어 내는 Real IP 모듈      
   --with-http_stub_status_module   // 서버 통계와 정보페이지를 생성하는 스터브 상태    
       
   * 기타 컴파일시 옵션 추가 할 수 있음 더많은 옵션 설명 -> http://webdir.tistory.com/238
       
  NginX 컴파일 설치      
  # make      
  # make install      
       
  NginX 환경설정 파일이 있는 폴더로 이동      
  # cd /usr/local/nginx-1.6.7/conf      
       
  NginX 환경설정 파일 vim editor 로 열기  *vim Editor 단축키 모음 -> http://mintnlatte.tistory.com/170
  # vi nginx.conf    
       
  NginX 환경설정 파일 설정 설명      
  http://ohgyun.com/479      
  http://ohgyun.com/480      
  http://ohgyun.com/481      
       
  시스템 방화벽 오픈      
  # sudo fuser -k 80/tcp      
       
  NginX 컴파일된 폴더 바로가기 생성 (운용시 가동중인 웹 서버 위치로 바로 이동할 수 있도록 심볼릭 링크 생성)
  # cd /usr/local      
  #ln -s./nginx-1.6.2 nginx      
       
  NginX 실행스크립트 등록      
  # vi /etc/init.d/nginx      
  변경후 저장      

  # chmod +x /etc/init.d/nginx      
  # chkconfig nginx on
  # chkconfig --list nginx
       
  NginX 설정 검사      
  # /etc/init.d/nginx configtest      
       
  NginX 실행
  # /etc/init.d/nginx start
 
  NginX 중지
  # /etc/init.d/nginx stop      
       
  * 등록후 NginX 실행시 오류 가 생길경우 실행스크립트 가 깨져서 ^M 이 들어가 있을 수있다.
  이경우    # vi /etc/init.d/nginx      로 vim etidor 를 연후    :%s^M$//g     를 입력 해주면 ^M 를 제거할 수 있다.
  단 ^M 을 그대로 입력하는것이 아니라 Ctrl+V 와 Ctrl+M 키를 눌러 입력 해야한다
 

=====================================================================================================
Nginx 설치하기


웹에서 접속하기 위해서 Web Server와 Web Application Server를 설치해 주어야 한다. 사용자의 요청에 대해서 Web Server는 정적 파일(HTML, CSS, Javascript, Image)에 대한 처리를 담당하고, Web Application Server는 동적인 처리에 대한 담담을 한다. 하지만 요즘은 Web Application Server에서 Web Server에 대한 처리가 모두 가능하고, 성능도 많이 개선되어서 구성의 주체가 효율적인 판단을 하면 된다.
필자는 Web Server로 많이 사용하는 Nginx를 설치할 것이다. Apache와 비교했을 때 여러 지표에서 뛰어난 성능을 보이고 있는데, Nginx는 비동기 이벤트 기반으로 만들어 져서, 더 적은 자원으로 더 많은 트래픽 처리를 감당할 수 있어서, Apache에 비해서 더 좋은 성능을 발휘하고 있는 부분들이 많다.
Nginx를 사용하는 유명한 곳으로는 Facebook, Netflix, Github, WordPress, Zynga, Sourceforge 등이 있다. 그 만큼 성능이 입증된 믿을 만한 Web Server란 이야기라고 생각하면 되겠다..
그럼 이제부터 설치 및 설정을 시작해 보자.
우선 Nginx를 설치하기 위해서는 Nginx의 의존성을 해결하기 위해서 먼저 설치해 주어야 하는 패키지들이 존재하기에 먼저 필요한 의존성 패키지부터 설치를 시작할 것이다. 그리고 실제 Nginx를 간단하게 설치해서 웹으로 접속해 볼 것이다. 더불어 Nginx에 대한 필요한 설정들도 알아볼 것이다.

NginX 의존성 lib 설치
A. gcc 설치
$ yum install gcc g++ cpp gcc-c++

B. PCRE (Perl Compatible Regular Expressions) 설치
Nginx를 컴파일, 설치하려면 펄 호환 정규표현식이 필요한데, rewirte와 HTTP Core Module이 PCRE 구문 정규 표현식을 사용하기 때문이다. pcre, pcre-devel 두 개의 lib 설치가 필요한다. PCRE는 Compile 버전의 라이브러리고, pcre-devel은 프로젝트를 Compile하기 위한 개발용 헤더와 소스다.
$ yum install pcre pcre-devel

C. zlib 설치
모듈에서 gzip 압축을 사용하기 위해 zlib가 필요한데, zlib와  zlib-devel 두개 모두 필요하다.
$ yum install zlib zlib-devel

D. OpenSSL 설치
OpenSSL은 범용 암호화 라이브러리다. 이미 설치되어 있을수도 있는데, 설치가 되어 있지 않다면 아래 명령어를 따라 설치하면 된다.
$ yum install openssl openssl-devel

Nginx 설치
Nginx를 yum을 통해서도 설치가 가능하지만 필자는 Nginx에 대해 좀 더 상세한 분석을 위해서 직접 파을을 다운 받아서 설정하도록 하겠다.
A. 파일 Download 및 압축해제
$ wget http://nginx.org/download/nginx-1.9.4.tar.gz
$ tar xzf nginx-1.9.4.tar.gz
$ cd nginx-1.9.4

B. 설정
Nginx 설정은 configure를 통해서 진행한다.
$ ./configure

아래 명령은 별도 다시 실행하지 않으도 무관하다. 필자가 필요한 설정들을 정의해서 했던 부분인데, 기본적으로 아래처럼 하지 않아도 "/usr/local/nginx"이 디폴트로 설정되어 있기 때문에 디폴트 하위로 필요한 것들이 만들어지게 되어 있다.
$ ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/usr/local/nginx/log/error.log --http-log-path=/usr/local/nginx/log/access.log --pid-path=/usr/local/nginx/run/nginx.pid --lock-path=/usr/local/nginx/run/nginx.lock --http-client-body-temp-path=/usr/local/nginx/cache/client_body_temp --http-proxy-temp-path=/usr/local/nginx/cache/proxy-temp --http-fastcgi-temp-path=/usr/local/nginx/cache/fastcgi-temp --http-uwsgi-temp-path=/usr/local/nginx/cache/uwsgi-temp --http-scgi-temp-path=/usr/local/nginx/cache/scgi-temp --user=ec2-user --group=ec2-user

디폴트로 제공하는 옵션에서 제거하고 싶은 것은 --without 으로 제거하고, 기본 외에 추가로 필요한 것은 --with 옵션으로 지정해 주면 된다. 그 외 서드파티 모듈들은 서드파티 모듈을 다운로드 받아서 컴파일할 때 --add-module 옵션을 사용해서 같이 컴파일하면 된다. "./configure –help" 명령어로 다양한 옵션을 확인할 수 있다.

주요 옵션 설명
--prefix : Nginx 가 설치되는 기본 디렉토리 (/usr/local/nginx)
--sbin-path : 엔진엑스의 바이너리 파일이 설치되는 경로 (/sbin)
--conf-path : 주 환경 설정 파일의 경로 (/conf/nginx.conf)
--error-log-path : 에러 로그 파일 (/log/error.log)
--http-log-path : http 접근 로그의 위치 (/log/access.log)
--pid-path : 엔진엑스 pid 파일 경로 (/run/nginx.pid)
--lock-path : Nginx lock 경로 (/run/nginx.lock)
--with-per_modules_path : 펄 모듈의 경로
--http-client-body-temp-path : 클라이언트 요청에 의한 임시 파일의 저장에 사용되는 디렉토리 (/cache/client_body_temp)
--http-proxy-temp-path: 프록시가 사용하는 임시 파일 위치 (/cache/proxy-temp)
--http-fastcgi-temp-path: (/cache/fastcgi-temp)
--http-uwsgi-temp-path: (/cache/uwsgi-temp)
--http-scgi-temp-path: (/cache/scgi-temp)
--user: Nginx 사용자 (nginx), 지정하지 않으면 nobody
--group: Nginx 그룹 (nginx), 지정하지 않으면 nobody

C. 빌드
$ make

D. 인스톨
$ make install
컴파일된 리소스를 인스톨 디렉토리로 복사한다. 위에서 설정한 prefix 하위로 복사된다.

F. Start
인스톨까지 완료되면, "/usr/local/nginx/" 하위에 필요한 파일들이 만들어지고, Nginx가 실행될 준비가 완료된 것이다. /usr/local/nginx/sbin으로 이동한 후에 nginx를 실행하면 서버가 구동이 된다. EC2의 Public IP로 접속하면 아래와 같은 화면을 볼 수 있을 것이다.
$ cd /usr/local/nginx/sbin
$ ./nginx

[VisualVM] JVM 모니터링 방법

1. JVM 모니터링 하려는 서버에서 모니터링 데몬 실행

 (1) JAVA_HOME/bin/tool.policy 생성
grant codebase "file:/JAVA_HOME/lib/tools.jar" {
    permission java.security.AllPermission;
};

 (2) /JAVA_HOME/bin/rmiregistry 1099 & 실행

 (3) /JAVA_HOME/bin/jstatd -J-Djava.security.policy=/JAVA_HOME/bin/tool.policy -p 1099 & 실행

2. VisualVM 클라이언트에서 해당 서버 접속

[Varnish] CentOS 설치

Install Varnish Cache on CentOS 6/7

Posted on 15/10/2015 by mervintankw - 0 Comments
Varnish Cache is a tool that helps to cache web pages for quicker loading of web pages.

Here we will cover how to install Varnish Cache on CentOS 6/7.


Step 1: Add EPEL

CentOS 6
rpm -ivh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

CentOS 7
rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm



Step 2: Download Varnish Cache

CentOS 6
rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.1.el6.rpm

CentOS 7
rpm --nosignature -i https://repo.varnish-cache.org/redhat/varnish-4.1.el7.rpm



Step 3: Install Varnish Cache

CentOS 6/7
yum install varnish -y



Step 4: Start Varnish Cache

CentOS 6
sudo service varnish start

CentOS 7
systemctl start varnish



Step 5: Set Varnish Cache to run on boot

CentOS 6
chkconfig --level 345 varnish on

CentOS 7
system enable varnish