ldap 구축이 시간이 걸려.

먼저 ip기반으로 nexus를 연동할 예정

앞단에 web서버(nginx)를 두어 ip blocking방법으로 방어함.


1. nginx, nexus 설치 및 연동


0) 설치 디렉토리 선정

mkdir /app/install


1) wget 설치

yum install wget



2) nginx 다운로드

wget nginx.org/download/nginx-1.2.7.tar.gz

tar zxvf nginx-1.2.7.tar.gz


3) rewrite 기능 때문에 pcre 설치

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

tar zxvf pcre-8.21.tar.gz 

cd /app/install/pcre-8.21

./configure --prefix=/usr/local

make

make install


* 참조 
http://nginx.org/en/docs/http/converting_rewrite_rules.html



4) nginx 설치 


/app/install/nginx-1.2.7># ./configure --prefix=/app/nginx

make 

make install 


5) nginx 설정


$ cat nginx.conf


worker_processes  1;


events {

    worker_connections  1024;

}


http {

    include       mime.types;

    default_type  application/octet-stream;


    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';


    sendfile        on;

    keepalive_timeout  65;


    gzip  on;


    server {

        listen       80;

        server_name  mvn.google.com;

        access_log  logs/mvn.access.log  main;


        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

        #rewrite ^ http://mvn.google.com:20050$request_uri permanent ;



        location / {

proxy_pass http://mvn.google.com:20050 ;

proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;

       proxy_redirect off;

       proxy_buffering off;

       proxy_set_header        Host            $host;

       proxy_set_header        X-Real-IP       $remote_addr;

       proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_connect_timeout   90;

proxy_send_timeout      90;

proxy_read_timeout      90;

}


allow 127.0.0.1;

allow 192.168.0.0/24;

allow 10.0.0.0/8;

 

deny all;


    }



}




6) nexus 잘 설치


7) nexus 설정 변경


# cat nexus.properties 


# Jetty section

application-port=20050

application-host=1.1.1.1

nexus-webapp=/app/nexus/nexus

nexus-webapp-context-path=/


# Nexus section

nexus-work=/app/sonatype-work/nexus

runtime=/app/nexus/nexus/WEB-INF







2. 테스트

HelloWorld maven 프로젝트 생성후 웹으로 확인

(추후 ldap 사용시 settings.xml 수정 필요)


mvn deploy:deploy-file -Durl=http://mvn.google.com/content/repositories/snapshots -DrepositoryId=com.google.tutorial -Dfile=HelloWorld-0.0.1-SNAPSHOT.jar -DgroupId=com.google.tutorial -DartifactId=HelloWorld -Dpackaging=jar -Dversion=0.0.1-SNAPSHOT



3. Nexus Schedule

Nexus에서 download index, publish index, remove snapshots from repository 작업이 돌아가게 함

rebuild metadata, update full index는 수동으로 작업하게 함




4. Nginx Log Rotate

nginx는 pipe 이슈가 있어서 log rotate를 USR1 시그널을 이용하는 듯 함. 

http://wiki.nginx.org/LogRotation 


/app/nginx/logs/mvn.access.log {

  daily

  missingok

  compress

  rotate 30

  dateext

  sharedscripts

  extension gz

  postrotate

    [ ! -f /app/nginx/logs/nginx.pid ] || kill -USR1 `cat /app/nginx/logs/nginx.pid`

  endscript

}




5. backup 은 rsync로 (급한대로..)


backup 서버 - service xinetd에 설정시킴

# cat /etc/rsyncd.conf 


[app]

    path = /app/

    uid = root

    gid = root

    comment = haha

    hosts allow = 127.0.0.1 1.1.1.11

    use chroot = yes

    read only = no




주서버-  crontab 설정


25 * * * *  rsync -avz --delete /app/ 1.1.1.11::app




Posted by '김용환'
,