참고 : http://mercurial.selenic.com/wiki/HgServeNginxWindows



Windows 에서 nginx를 proxy로 사용하여 인증하는 방식.

TortoiseHg 가 C:\Program Files\TortoiseHg 폴더에 설치되어 있다고 가정함.

다운로드

Windows Service Wrapper 다운로드 (winsw-1.9-bin.exe 라고 가정)
http://maven.dyndns.org/2/com/sun/winsw/

nginx 다운로드 (nginx-1.0.11.zip 이라고 가정)
http://nginx.org/en/download.html




nginx 설정

1. C:\nginx 에 nginx-1.0.11.zip 압축 해제
2. C:\nginx 에 servicelogs 폴더 생성
3. C:\nginx 에 winsw-1.9-bin.exe 파일을 복사하고, 파일명을 nginx-service.exe 로 수정
4. C:\nginx 에 nginx-service.xml 파일을 생성하고 내용을 아래처럼 입력

<service>
    <id>nginx</id>
    <name>nginx</name>
    <description>nginx</description>
    <executable>c:\nginx\nginx.exe</executable>
    <logpath>c:\nginx\servicelogs</logpath>
    <logmode>roll</logmode>
    <depend>Mercurial</depend>
    <startargument>-p c:\nginx</startargument>
    <stopargument>-p c:\nginx -s stop</stopargument>
</service>

5. C:\nginx\conf\nginx.conf 파일을 열어 VirtualHost 하나 추가.
그냥 아래의 내용을 복사해서 Mercurial proxy 전용으로 쓰자.

worker_processes  1;
 
events {
    worker_connections  1024;
}
 
http {
    include       mime.types;
    default_type  application/octet-stream;
 
    sendfile        on;
 
    keepalive_timeout  65;
 
    server {
        listen       5000;
        server_name  mis-srv;
        access_log   logs/mercurial.access.log;
        error_log    logs/mercurial.error.log;
        location / {
            auth_basic           "Mercurial restricted";
            auth_basic_user_file passwd;
            proxy_pass          
http://localhost:5500;
        }
    }
}


6. C:\nginx\conf\passwd 파일을 생성하고 계정설정을 입력. 형식은 username:password
아래는 username이 test이고 비밀번호가 testpass인 계정설정의 예.
test:testpass






Mercurial 설정

1. C:\nginx\hg 디렉토리 생성
2. C:\nginx\hg\servicelogs 디렉토리 생성
3. C:\nginx 에 winsw-1.9-bin.exe 파일을 복사하고, 파일명을 hg-service.exe로 수정
4. C:\nginx 에 hg-service.xml 파일을 생성하고 내용을 아래와 같이 입력

<service>
    <id>Mercurial</id>
    <name>Mercurial</name>
    <description>Mercurial</description>
    <executable>cmd.exe</executable>
    <logpath>c:\nginx\hg\servicelogs</logpath>
    <logmode>roll</logmode>
    <depend></depend>
    <startargument>/c "c:\nginx\hg\hg-run start"</startargument>
    <stopargument>/c "c:\nginx\hg\hg-run stop"</stopargument>
</service>

5. C:\nginx\hg 에 hg-run.bat 파일을 만들고 내용을 아래와 같이 입력
@echo off
    if "%1"=="start" (goto :start)
:stop
    taskkill /F /IM hg.exe /T
    goto :end
:start
    "C:\Program Files\TortoiseHg\hg.exe" serve --address localhost --port 5500 --web-conf c:\nginx\hg\hgweb.conf
:end

6. C:\nginx\hg 에 hgweb.conf 파일을 만들고 내용을 아래와 같이 입력
(아래는 2개의 저장소를 serve 하는 예제)
[web]
push_ssl = false
allow_push = *
 
[paths]
real = C:\Repo\real
dev  = C:\Repo\dev






서비스

1. cmd.exe를 실행시켜 cd 명령어로 C:\nginx 디렉토리로 이동한 다음, 다음 명령어를 실행하여 서비스 등록
C:\nginx> nginx-service install
C:\nginx> hg-service install


2. 윈도우 시작메뉴의 제어판 > 관리도구 > 서비스를 실행한 후, Mercurial과 nginx를 찾아 시작시킴.
다음 재부팅부터는 자동실행됨.




결론

위의 설정대로 완료해서 서비스까지 시작하면 아래 2개의 경로로 clone 등이 가능하다.

http://ip_address:5000/real
http://ip_address:5000/dev



결론2. ssh 가 제일 편한 듯!





Posted by bloodguy
,