Https 를 적용해야 할 경우 간단하게 만들어서 테스트를 해볼 수 있다.

그 준비물인 사설 인증서를 생성해 보자.

 

Step 1. private key 생성하기

 

whitelife@whitelife:~/openssl/test$ openssl genrsa > key.pem

 

-----BEGIN RSA PRIVATE KEY-----
MIIBPAIBAAJBAKoBPDY0MJvDwAOsH1D3ITHtHiH/38HX0FwDT3T3wTJRerr8rwUl
bqnWuD8v054z/Kx+PlDRTVoNICkkiFgJKv8CAwEAAQJBAJCCFEiO/HKrZmC4wrX0
G8dwo5iLBAymAnr0ZWor35GAxbG3KFh6cj7M0oeUIJSniIKhUBWg4eq64tS/0sTX
62ECIQDfUWa8GoQxr26TPmLUBVXyxw9fb+2BVYffvawkJoGJIwIhAMLidX73oZMu
k/XHcCcFoWkx1jxtVsHfcPODVfJRD2p1AiB+ti922AzeLE6vmZx19TkZcj2Ux2ua
ES/xkivUr0ycxQIhAIbqM6E0WZ0E79WEvjWlhjrHD6NBpoAM6asLTyKzz1JJAiEA
j1pwThKycdp2s1q8AWLIeKxOGGTVfQfHtt2r58wpF9o=
-----END RSA PRIVATE KEY-----

 

Step 2-1.  CSR 생성

 

whitelife@whitelife:~/openssl/test$ openssl req -new -key key.pem > csr.pem


You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:82
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
-----BEGIN CERTIFICATE REQUEST-----
MIH/MIGqAgEAMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw
HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwXDANBgkqhkiG9w0BAQEF
AANLADBIAkEAqgE8NjQwm8PAA6wfUPchMe0eIf/fwdfQXANPdPfBMlF6uvyvBSVu
qda4Py/TnjP8rH4+UNFNWg0gKSSIWAkq/wIDAQABoAAwDQYJKoZIhvcNAQEFBQAD
QQBoQBxqUzqQij8nVk6evB48s+HEfwOVlXjN91Lljq+Pt0flBQk0Bcyg7st6LFI0
f3lUp2NH2Buwz1rHvHvksPG1
-----END CERTIFICATE REQUEST-----

 

Step 2-2.  X.509 인증서 생성

private key, csr 을 이용하여 공인 인증서 생성 x509 구조로 변환 sha1 을 적용 한다.

 

whitelife@whitelife:~/openssl/test$ openssl req -x509 -nodes -sha1 -key key.pem -days 3600 -in csr.pem -out cert.pem


-----BEGIN CERTIFICATE-----
MIIB0zCCAX2gAwIBAgIJAO0e6iF6uOhjMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQwHhcNMTMwNDI0MDkzOTM1WhcNMjMwMzAzMDkzOTM1WjBF
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKoB
PDY0MJvDwAOsH1D3ITHtHiH/38HX0FwDT3T3wTJRerr8rwUlbqnWuD8v054z/Kx+
PlDRTVoNICkkiFgJKv8CAwEAAaNQME4wHQYDVR0OBBYEFKMjMlhvCA1jlu6rv9T0
SEKuMOWEMB8GA1UdIwQYMBaAFKMjMlhvCA1jlu6rv9T0SEKuMOWEMAwGA1UdEwQF
MAMBAf8wDQYJKoZIhvcNAQEFBQADQQB528m7Ytn0DEtGDaj7NyWrjFBQgCsYMikf
VMdqJtsh44t+gnslVlSfpszWFWJGwpPdWosGSbeAUx0l89B6mw0m
-----END CERTIFICATE-----

 

결과.

파일이 생성된 모습을 확인 할 수 있다.

 

drwxrwxr-x 2 whitelife whitelife 4096  4월 24 18:36 ./
drwxrwxr-x 3 whitelife whitelife 4096  4월 24 18:19 ../
-rw-rw-r-- 1 whitelife whitelife  692  4월 24 18:39 cert.pem
-rw-rw-r-- 1 whitelife whitelife  420  4월 24 18:30 csr.pem
-rw-rw-r-- 1 whitelife whitelife 9655  4월 24 18:36 help
-rw-rw-r-- 1 whitelife whitelife  497  4월 24 18:22 key.pem

 

 

 

보통 리눅스에 설치 했을 경우 경로는 /etc/nginx/ 이다.

 

Step 1.  Vitrual Host Configs 경로 설정하기

 

// ... 

 

##  
# Virtual Host Configs
## 

include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;

 

// ...

 

Step 2.  Vitrual Host Configs 설정하기

default 설정은 /etc/nginx/site-enabled/default 를 참고 한다.

 

server {

// ...

}

 

위와 같은 형태 이다. 아래 자주 쓰는 설정을 소개 한다.

 

 분류

설명 

root

 

  root /usr/share/nginx/www;

  image, javascript, html의 실제 경로

 

index

 

  index index.html index.htm;

  requestUri가 / 로 왔을 경우 요청 되는 페이지

 

server_name

 

  server_name localhost;

  server domain 명

 

location

 

  location / {

    proxy_pass  http://127.0.0.1:8080;

  }

  requestUri 에 따른 설정 접근 제한, was 로 요청 위임등 이 가능하다.

  - proxy_pass: 요청을 받아서 해당 주소로 요청을 위임 한다.

 

rewrite 

  

  rewrite ^/(.*)  http://www.test.co.kr/$1

  특정 요청이 왔을 경우 패턴에 의해서 재요청 한다.

 

 

Step 3.  Sample

rewrite는 사용 용도에 따라 location 안에 같이 사용이 가능하다.

 

server {

  root /usr/share/nginx/www;

  index index.html index.htm;

 

  server_name localhost;

 

  location /test {

    rewrite ^/(.*)  http://www.test.co.kr/$1

  }

 

  location / {

    proxy_pass  http://127.0.0.1:8080;

  } 

}

 

설정이 JSON 형태라 Apache 에 비해 간단 하고 명확한거 같다.

 

※ 참고 사이트: http://nginx.org/en/docs/

 

'Server,Was' 카테고리의 다른 글

Nginx 403 (13: Permission denied) 현상 해결하기  (0) 2013.04.26
Openssl 사설 인증서 만들기  (0) 2013.04.24
Nginx Ubuntu에서 설치하기  (0) 2013.04.23
Nginx OSX에서 설치하기  (0) 2013.04.23
war 파일 생성 하기  (0) 2013.02.17


nginx를 설치합시다.~


Step 1.  nginx 설치 하기



whitelife@ubuntu:~$ sudo apt-get install nginx

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following extra packages will be installed:

  nginx-common nginx-full

The following NEW packages will be installed:

  nginx nginx-common nginx-full

0 upgraded, 3 newly installed, 0 to remove and 337 not upgraded.

Need to get 407 kB of archives.

After this operation, 1,229 kB of additional disk space will be used.

Do you want to continue [Y/n]? Y 



Step 2.  nginx 시작하기



whitelife@ubuntu:~$ sudo service nginx start

Starting nginx: nginx.

whitelife@ubuntu:~$ 



화면을 확인 하자.


성공이다.~



'Server,Was' 카테고리의 다른 글

Openssl 사설 인증서 만들기  (0) 2013.04.24
Nginx 기본 설정하기  (0) 2013.04.24
Nginx OSX에서 설치하기  (0) 2013.04.23
war 파일 생성 하기  (0) 2013.02.17
Tomcat7 Web Application Deploy 하기  (0) 2013.02.01


nginx를 설치합시다.~


Step 1.  PCRE (Perl Compatible Regular Expressions) 설치하기

Perl 호환 정규식 이라고 한다. 먼지는 잘 모르겠지만... 설치해야 한다. 



curl -O ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz

tar zxvf pcre-8.21.tar.gz

./configure --prefix=/usr/local

make

sudo make install



Step 2.  nginx 설치하기

osx에는 svn 이 내장 되어 있다. 



svn checkout svn://svn.nginx.org/nginx/tags/release-1.3.16

./auto/configure
make
sudo make install



Step 3.  nginx 시작하기

command 에 대한 도움말을 볼 수 있다.



sudo /usr/local/nginx/sbin/nginx -?

nginx version: nginx/1.3.16

Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]


Options:

  -?,-h         : this help

  -v            : show version and exit

  -V            : show version and configure options then exit

  -t            : test configuration and exit

  -q            : suppress non-error messages during configuration testing

  -s signal     : send signal to a master process: stop, quit, reopen, reload

  -p prefix     : set prefix path (default: /usr/local/nginx/)

  -c filename   : set configuration file (default: conf/nginx.conf)

  -g directives : set global directives out of configuration file



서버를 시작해 보자.



sudo /usr/local/nginx/sbin/nginx



확인하기.

성공이다~


※ 참고 사이트

pcre - http://www.pcre.org/

nginx - http://nginx.org/en/download.html


'Server,Was' 카테고리의 다른 글

Nginx 기본 설정하기  (0) 2013.04.24
Nginx Ubuntu에서 설치하기  (0) 2013.04.23
war 파일 생성 하기  (0) 2013.02.17
Tomcat7 Web Application Deploy 하기  (0) 2013.02.01
Apache Friends XAMPP 설치 하기  (0) 2013.01.30


사용법: jar {ctxui}[vfm0Me] [jar 파일] [manifest 파일] [시작 지점] [-C 디렉토리] 파일 ...
옵션:
    -c  새 아카이브 만들기
    -t  아카이브에 대한 내용 목록 테이블
    -x  명명된(또는 모든) 파일을 아카이브에서 추출
    -u  기존 아카이브 업데이트
    -v  표준 출력에 세부 정보 표시 출력 생성
    -f  아카이브 파일 이름 지정
    -m  지정한 매니페스트 파일로부터 매니페스트 정보 포함
    -e  jar 실행 파일에 번들로 제공된 독립 실행형 응용 프로그램의
        응용 프로그램 시작 지점 지정
    -0  저장 전용, ZIP 압축 사용 안 함
    -M  항목에 대해 매니페스트 파일을 만들지 않음
    -i  지정한 jar 파일에 대한 색인 정보 생성
    -C  지정한 디렉토리로 변경하고 다음 파일 포함
어떤 파일이 디렉토리면 재귀적으로 처리됩니다.
매니페스트 파일 이름, 아카이브 파일 이름 및 시작 지점 이름은
'm', 'f' 및 'e' 플래그와 동일한 순서로 지정됩니다.

예 1: classes.jar라는 아카이브에 두 클래스 파일을 아카이브하는 방법:
       jar cvf classes.jar Foo.class Bar.class
예 2: 기존의 매니페스트 파일 'mymanifest'를 사용하여
           foo/ 디렉토리의 모든 파일을 'classes.jar'로 아카이브하는 방법:
       jar cvfm classes.jar mymanifest -C foo/ .



whitelife@whitelife-server ~/was $ jar cf whitelife.war *


위와 같이 실행 하면 해당 경로에 있는 파일이 war로 생성 된다.


'Server,Was' 카테고리의 다른 글

Nginx Ubuntu에서 설치하기  (0) 2013.04.23
Nginx OSX에서 설치하기  (0) 2013.04.23
Tomcat7 Web Application Deploy 하기  (0) 2013.02.01
Apache Friends XAMPP 설치 하기  (0) 2013.01.30
jBoss7 Path 설정 하기  (0) 2013.01.30


Tomcat7은 설치 되어 있다고 가정 한다. War 파일도 준비해야 한다.


Step 1.  Admin 계정 만들기

D:\Develop\was\tomcat\apache-tomcat-7.0.35\conf\tomcat-users.xml 파일을 수정 하자.



<?xml version='1.0' encoding='utf-8'?>

<!--

  Licensed to the Apache Software Foundation (ASF) under one or more

  contributor license agreements.  See the NOTICE file distributed with

  this work for additional information regarding copyright ownership.

  The ASF licenses this file to You under the Apache License, Version 2.0

  (the "License"); you may not use this file except in compliance with

  the License.  You may obtain a copy of the License at


      http://www.apache.org/licenses/LICENSE-2.0


  Unless required by applicable law or agreed to in writing, software

  distributed under the License is distributed on an "AS IS" BASIS,

  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  See the License for the specific language governing permissions and

  limitations under the License.

-->

<tomcat-users>

<!--

  NOTE:  By default, no user is included in the "manager-gui" role required

  to operate the "/manager/html" web application.  If you wish to use this app,

  you must define such a user - the username and password are arbitrary.

-->

<!--

  NOTE:  The sample user and role entries below are wrapped in a comment

  and thus are ignored when reading this file. Do not forget to remove

  <!.. ..> that surrounds them.

-->

<!--

  <role rolename="tomcat"/>

  <role rolename="role1"/>

  <user username="tomcat" password="tomcat" roles="tomcat"/>

  <user username="both" password="tomcat" roles="tomcat,role1"/>

  <user username="role1" password="tomcat" roles="role1"/>

-->

<role rolename="manager-gui" />

      <user username="min" password="min" roles="manager-gui" />


</tomcat-users>



관리자에 해당하는 권한을 주고 아이디를 생성 했다.


Step 2.  서버 시작 하기


  • Windows -> D:\Develop\was\tomcat\apache-tomcat-7.0.35\bin\startup.bat
  • Linux -> D:\Develop\was\tomcat\apache-tomcat-7.0.35\bin\startup.sh

OS에 맞는 파일을 실행 한다. 


2013. 2. 1 오후 3:04:24 org.apache.catalina.core.AprLifecycleListener init
정보: Loaded APR based Apache Tomcat Native library 1.1.24 using APR version 1.4.6.
2013. 2. 1 오후 3:04:24 org.apache.catalina.core.AprLifecycleListener init
정보: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2013. 2. 1 오후 3:04:24 org.apache.catalina.core.AprLifecycleListener initializeSSL
정보: OpenSSL successfully initialized (OpenSSL 1.0.1c 10 May 2012)
2013. 2. 1 오후 3:04:25 org.apache.coyote.AbstractProtocol init
정보: Initializing ProtocolHandler ["http-apr-8080"]
2013. 2. 1 오후 3:04:25 org.apache.coyote.AbstractProtocol init
정보: Initializing ProtocolHandler ["ajp-apr-8009"]
2013. 2. 1 오후 3:04:25 org.apache.catalina.startup.Catalina load
정보: Initialization processed in 1208 ms
2013. 2. 1 오후 3:04:25 org.apache.catalina.core.StandardService startInternal
정보: Starting service Catalina
2013. 2. 1 오후 3:04:25 org.apache.catalina.core.StandardEngine startInternal
정보: Starting Servlet Engine: Apache Tomcat/7.0.35
2013. 2. 1 오후 3:04:25 org.apache.catalina.startup.HostConfig deployWAR
정보: Deploying web application archive D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\ROOT.war
2013. 2. 1 오후 3:04:26 org.apache.catalina.startup.HostConfig deployDirectory
정보: Deploying web application directory D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\docs
2013. 2. 1 오후 3:04:26 org.apache.catalina.startup.HostConfig deployDirectory
정보: Deploying web application directory D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\examples
2013. 2. 1 오후 3:04:26 org.apache.catalina.startup.HostConfig deployDirectory
정보: Deploying web application directory D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\host-manager
2013. 2. 1 오후 3:04:26 org.apache.catalina.startup.HostConfig deployDirectory
정보: Deploying web application directory D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\manager
2013. 2. 1 오후 3:04:26 org.apache.coyote.AbstractProtocol start
정보: Starting ProtocolHandler ["http-apr-8080"]
2013. 2. 1 오후 3:04:26 org.apache.coyote.AbstractProtocol start
정보: Starting ProtocolHandler ["ajp-apr-8009"]
2013. 2. 1 오후 3:04:26 org.apache.catalina.startup.Catalina start
정보: Server startup in 1546 ms


Step 3.  관리자 페이지 접속 하기

따로 설정을 하지 않았다면 http://localhost:8080/manager 로 접속 한다.



방금 만들었던 Admin 계정을 입력 한다.



위와 같은 페이지가 뜨면 성공 이다. Applications 현황이나, Server Status를 볼 수 있다. 


Step 4.  War Deploy 하기

스크롤을 내리다 보면 아래와 같은 메뉴가 있다.



실행 절차


  1. 찾아보기 버튼을 클릭하여 War 파일을 추가 한다.
  2. Deploy 버튼을 클릭 한다.

참고) War 파일의 이름이 Context Path 가 된다. 아래 그림에 /whitelife 라고 추가 된 것을 볼 수 있다.



2013. 2. 1 오후 3:18:11 org.apache.catalina.startup.HostConfig deployWAR

정보: Deploying web application archive D:\Develop\was\tomcat\apache-tomcat-7.0.35\webapps\whitelife.war



정상적으로 Deploy가 된 경우, Applications 제일 밑에 추가 된 것을 볼 수 있다.

상황에 따라서 해당 Application을 Stop, Reload, Undeploy 할 수 있다.


Step 5.  Hello World !!! 확인하기


위 페이지가 떳다면 성공이다. 



XAMPP는 통합 웹 개발 환경을 제공 한다. 


  • Apache Web Server
  • MySQL
  • FileZilla
  • Mercury
  • Tomcat 


위 항목들을 지원 한다.


Step 1. XAMPP 다운로드 하기

http://www.apachefriends.org/en/xampp.html 에 접속한 후 OS에 맞는 설치 파일을 받는다.



Windows 버전을 설치 한다. 다음 버튼을 누르다 보면 완료 될 것이다.


Step 2. XAMPP 실행 하기

설치 된 경로 중 xampp-control.exe 파일을 실행하자. 아래와 같은 화면이 나오면 성공이다.





jBoss7은 설치 되어 있어야 하고, Web Application 기준으로 설명 한다.


아래 그림은 일반적인 Web Application의 폴더 구조 이다. /WEB-INF/ 안에 해당 파일을 만들어 보자.




<?xml version="1.0" encoding="UTF-8"?>

<!-- JBoss, Home of Professional Open Source Copyright 2012, Red Hat, Inc. 

    and/or its affiliates, and individual contributors by the @authors tag. See 

    the copyright.txt in the distribution for a full listing of individual contributors. 

    Licensed under the Apache License, Version 2.0 (the "License"); you may not 

    use this file except in compliance with the License. You may obtain a copy 

    of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 

    by applicable law or agreed to in writing, software distributed under the 

    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 

    OF ANY KIND, either express or implied. See the License for the specific 

    language governing permissions and limitations under the License. -->


<!-- Configure usage of the security domain "other" -->

<jboss-web>

   <context-root>/</context-root>

</jboss-web>



jBoss가 Start 될 때, Path를 설정 하는 부분이다. 


  • / -> http://localhost:8080/
  • /test -> http://localhost:8080/test

이런 형태로 적용이 된다.


+ Recent posts