Skip to content

CHICPRO

  • Life Log
  • Cycling Log
  • Photo Log
    • Portrait
    • Landscape
    • Flower
    • Etc
  • Coding Log
  • Information

nginx 리버스 프록시 설정

2014-01-10 by 편리

nginx로 리버스 프록시를 설정하는 방법이다. nginx에 포함된 upstream 모듈을 이용하는 것으로 서버가 로드밸런싱 기능을 하도록 할 수 있다. 또는 마스터 서버가 다운됐을 때 백업서버로 연결을 전환하는 것도 할 수 있다. 아래 설정은 마스터 서버가 다운됐을 때 백업서버로 연결을 돌리는 것이다.

    upstream wwwservers {
        #ip_hash;
        least_conn;

        server 192.168.1.101 max_fails=3 fail_timeout=10s;
        server 192.168.1.102 backup;
    }

    server {
        listen       80;
        server_name  www.example.com;

        proxy_redirect          off;
        client_max_body_size    500m;
        client_body_buffer_size 256k;

        location / {
            proxy_pass  http://wwwservers;
            proxy_set_header    Host    $http_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_buffers               4 32k;
            proxy_temp_file_write_size  64k;
        }       
    }

위 내용을 nginx.conf 파일 http 블럭 안에 넣어주면 된다. 3대의 테스트 서버에 nginx를 설치하고 1대는 로드밸런서로 나머지 두 대는 웹서버로 세팅하고 테스트했는데 마스터 서버가 다운됐을 때 바로 백업서버로 전환이 되는 걸 확인했다. 또 마스터 서버가 복구되면 다시 마스터 서버로 접속이 전환되는 걸 확인했다.

참고자료
http://blog.jsdelivr.com/2013/01/nginx-load-balancing-basics.html
http://nginx.org/en/docs/http/ngx_http_upstream_module.html

Post navigation

Previous Post:

rsync 설정

Next Post:

안드로이드 SSH Client JuiceSSH

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • php 배열 연산에서 + 와 array_merge 의 차이
  • pcntl_fork 를 이용한 다중 프로세스 실행
  • 아이폰 단축어를 이용하여 주중 공휴일엔 알람 울리지 않게 하기
  • 구글 캘린더 전체일정 재동기화
  • OpenLiteSpeed 웹서버에 HTTP 인증 적용
  • OpenLiteSpeed 웹어드민 도메인 연결
  • WireGuard를 이용한 VPN 환경 구축
  • Ubuntu 22.04 서버에 OpenLiteSpeed 웹서버 세팅
  • 맥 vim 세팅
  • 우분투 시스템 터미널쉘 zsh 로 변경

Recent Comments

  • 편리 on 업무관리용 그누보드 게시판 스킨
  • 임종섭 on 업무관리용 그누보드 게시판 스킨
  • 캐논 5D 펌웨어 | Dslr 펌웨어 업그레이드 방법 82 개의 베스트 답변 on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • Top 5 캐논 5D 펌웨어 Top 89 Best Answers on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • 편리 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 임팀장 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 편리 on Notepad++ NppFTP 플러그인 수동 설치
  • paul-j on Notepad++ NppFTP 플러그인 수동 설치
  • YS on Windows 10 iCloud 사진 저장 폴더 변경
  • 편리 on Docker를 이용한 Centos7 + httpd + php 5.4 개발환경 구축

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2025 CHICPRO | Built using WordPress and SuperbThemes