안녕리눅스 3 User Guide
  • Introduction
  • Chapter 1. 안녕 리눅스 3 \/ CentOS 7.2 차이점
  • Chapter 2. Access Control
    • 안녕 리눅스 방화벽 설정
      • 기본 설정
      • Inbound 제어
      • Outbound 제어
      • brute force attack 제어
      • User defined rule 제어
      • 특정 국가에서의 접속 제어
      • oops-firewall 실행 방법
    • Shell login Control (with PAM)
      • login 가능한 account 제한
      • login account chroot
      • Google OTP를 이용한 2 factor 인증
    • 인증 통합 (Authentification\/Authorization Intergrate)
      • Openldap
        • Master Server 설정
        • SSL 설정
        • Slave Server 설정
        • Replication 설정
        • LDAP 클라이언트 인증 연동 설정
        • LDAP data 관리
        • Sudo LDAP 연동
      • NIS
      • Active Directory
  • Chapter 3. Web control
    • httpd
    • nginx
    • lighttpd
    • PHP
    • Web Access Control
      • Apache 2.4
      • Nginx
      • lighttpd
    • Web Monitor agent
  • Chapter 4. JVM 운영
  • Chapter 5. DNS 운영
    • 기본 설정
    • 신규 도메인 설정
    • Slave DNS 구성
    • Inverse Domain 설정
    • DNSSEC 설정
    • GeoDNS 설정
    • Domain 위임
    • IDN
    • Troble Shooting
  • Chapter 6. Time Server 운영
    • Chrony
    • NTP
  • Chapter 7. VPN 운영
  • Chapter 8. SMTP 운영
  • 안녕 리눅스 White Paper
    • Disk Partition Aligment
  • 안녕 리눅스 알려진 버그
  • 안녕 리눅스 3 패키지 일람
    • [AN:core]
      • annyung-release
      • byspam
      • check-utils
      • genpasswd
      • httpd-conf
      • httpd-krisp
      • httpd-nis
      • httpd-url
      • kmod-geoip
      • l4vip
      • ldap-auth-utils
      • libchardet
      • libimginfo
      • libipcalc
      • libkrisp
      • mariadb-aes256
      • olibc
      • oops-firewall
      • perl-KRISP
      • perl-ModuleList
      • php-chardet
      • php56-chardet
      • php71-chardet
      • php-common
      • php56-common
      • php71-common
      • php-fpm-conf
      • php56-fpm-conf
      • php71-fpm-conf
      • php-geoip
      • php56-geoip
      • php71-geoip
      • php-korean
      • php56-korean
      • php71-korean
      • php-krisp
      • php56-krisp
      • php71-krisp
      • php-nis
      • php56-nis
      • php71-nis
      • php-pear-KSC5601
      • php-pear-ipcalc
      • php-pear-krisp
      • php-pear-oops-key
      • procdump
      • python-chardet
      • python-krisp
      • remount
      • utf8-profile
      • whois
      • yum-annyung
    • [AN:base]
      • apr
      • authconfig
      • bash
      • bind
      • chrony
      • coreutils
      • ctags
      • cvs
      • ecj
      • filesystem
      • GeoIP
      • gperftools
      • httpd
      • initscrtips
      • iptables
      • java-1.8.0-openjdk
      • javapacakges-tools
      • linuxdoc-tools
      • mariadb
      • memcached
      • net-tools
      • ntp
      • openssh
      • openssl
      • pam
      • php
      • procmail
      • procps-ng
      • redhat-rpm-config
      • rootfiles
      • rsyslog
      • sendmail
      • setup
      • shadow-utils
      • sudo
      • systemd
      • sysvinit-tools
      • tomcat
      • traceroute
      • unzip
      • util-linux
      • vim
      • xinted
    • [AN:xless]
    • [AN:addon]
      • authbind
      • cronolog
      • google-authenticator
      • hping3
      • httpd-fcgid
      • imap
      • jfbterm
      • jlint
      • libevent14
      • libnet
      • libnetfilter_acct
      • lighttpd
      • mhash
      • mimetex
      • mm
      • netdata
      • netperf
      • nginx
      • openvpn
      • pdnsd
      • perl-CSS-DOM
      • php-pecl-apcu
      • php56-pecl-apcu
      • php71-pecl-apcu
      • php-pecl-memcache
      • php56-pecl-memcache
      • php71-pecl-memcache
      • php-pecl-oauth
      • php56-pecl-oauth
      • php71-pecl-oauth
      • php-pecl-xdebug
      • php56-pecl-xdebug
      • php71-pecl-xdebug
      • php56
      • php71
      • proftpd
      • python-Mako
      • python-MarkupSafe
      • python-mcrypt
      • python-openpyxl
      • python-xlrd
      • re2c
      • redis
      • rudiments
      • splint
      • sqlite32
      • sqlrelay
      • tomcat-native
    • [AN:plus]
  • 안녕 리눅스 Upgrade Guide
Powered by GitBook
On this page
  • 1. IP based access control
  • 2. referer based access control
  • 3. User Agent based access control
  • 4. Country/ISP based access control
  • 4.1. GeoIP
  • 4.2. krisp
  • 5. User based access control
  • 5.1. password list 생성
  • 5.2. 인증 설정

Was this helpful?

  1. Chapter 3. Web control
  2. Web Access Control

Nginx

목차 1. IP based access control 2. referer based access control 3. User Agent based access control 4. Country/ISP based access control 5. User based access control

1. IP based access control

location / {
  allow 192.168.0.0/24;
  deny all;
}
  • 값은 IP 주소, CIDR, unix socket, all 을 사용할 수 있습니다.

2. referer based access control

ngx_http_referer module을 이용하여 제어를 합니다.

location /photo/ {
  valid_referers none blocked server_names *.example.com example.* www.example.org/galleries/ ~\.google\.;
  if ( $invalid_referer) {
    return 403;
  }
}
  • none - referer 없이 direct로 접속하는 경우

  • blocked - Referer filed가 존재하기는 하지만, 방화벽이나 proxy 서버에 의해서 지워지거나 또는 변조된 경우를 의미합니다. 예를 들어 http:// 또는 https:// 로 시작하지 않는 referer 주소를 들 수 있습니다.

  • 그 외의 referer 표현법은 ngx_http_referer_module 문서를 참조 하십시오.

3. User Agent based access control

$http_user_agent 환경 변수를 이용하여 제어를 합니다.

location / {
  # protect Bing bot and Google bot
  if ( $http_user_agent ~* (bing|google) ) {
    return 403;
  }
}

4. Country/ISP based access control

Nginx에서의 국가 또는 ISP 제어는 GeoIP와 krisp를 이용하여 가능 합니다.

둘 중, 어느 것을 사용하는냐는 사용자의 선택이지만, 국내의 IP 및 ISP 정보를 취급할 경우에는 krisp를 사용하는 것이 더 정확 합니다.

참고!

  • GeoIP 모듈은 ISP 정보를 제공하지 않습니다.

  • 안녕에서 기본 제공하는 krisp database에는 국내의 ISP 정보만 있습니다. (해외 ISP 정보는 들어 있지 않습니다. GeoISP를 이용하여 custom database를 만들 수 있습니다.)

  • krisp database는 KISA의 한국 IP database를 기반으로 하여 제작 되어 국내 환경에는 GeoIP보다 정확도가 높습니다.

4.1. GeoIP

GeoIP module을 사용하기 위한 자세한 설정은 nginx ngx_http_geoip_module 문서를 참고 하십시오.

location = /ko/ {
  if ( $geoip_country_code != KR ) {
    return 403;
  }
}

4.2. krisp

krisp module을 사용하기 위한 자세한 설정은 nginx ngx_http_krisp module 문서를 참고 하십시오.

location /ko/ {
  if ( $krisp_country_code = KR ) {
    if ( $krisp_isp_code = KORNET ) {
      return 403;
    }
  }
}

5. User based access control

5.1. password list 생성

google에서 "htpasswd web generator" 로 검색을 하면 web상에서 password list를 만들어 주는 tool들을 쉽게 찾을 수 있습니다.

또는, http://nginx.org/en/docs/http/ngx_http_auth_basic_module.html#auth_basic_user_file 문서를 참고 하십시오.

5.2. 인증 설정

localtion / {
  auth_basic "Restricted Content";
  auth_basic_user_file /etc/nginx/.htpasswd;

  if ( $remote_user !~ ^(john|smith|joe)$ ) {
    return 403;
  }
}

*

PreviousApache 2.4Nextlighttpd

Last updated 5 years ago

Was this helpful?