'nginx'에 해당되는 글 4건

  1. 2021.12.07 [Nginx] 설치 하기.
  2. 2019.09.19 [Nginx] nginx + ldap 연동
  3. 2017.02.02 [AWS] ELB + http to https + Nginx 설정
  4. 2016.11.23 [Nginx] osx 에 nginx 설치 하기 - brew install

[Nginx] 설치 하기.

ITWeb/개발일반 2021. 12. 7. 09:28

docker 를 이용해서 쉽게 구성이 가능 하지만 소스 내려 받아서 빌드 해서 설치 하는 것도 필요해서 정리해 봅니다.

필요한 모듈은 추가적으로 구성이 가능 하니까 필요에 따라 설치 하세요.

 

- 사전 준비 환경

$ wget https://nginx.org/download/nginx-1.20.2.tar.gz
$ wget http://zlib.net/zlib-1.2.11.tar.gz
$ wget --no-check-certificate http://www.openssl.org/source/openssl-1.1.1l.tar.gz
$ wget --no-check-certificate http://www.openssl.org/source/openssl-3.0.0.tar.gz
$ wget https://github.com/openresty/headers-more-nginx-module/archive/refs/tags/v0.33.tar.gz
$ wget https://github.com/vozlt/nginx-module-vts/archive/refs/tags/v0.1.18.tar.gz


- 설치 인스턴스 전송

$ scp nginx-1.20.2.tar.gz $TARGET:/home/user/download/
$ scp zlib-1.2.11.tar.gz $TARGET:/home/user/download/
$ scp openssl-1.1.1l.tar.gz $TARGET:/home/user/download/
$ scp openssl-3.0.0.tar.gz $TARGET:/home/user/download/
$ scp v0.33.tar.gz $TARGET:/home/user/download/headers-more-nginx-module-0.33.tar.gz
$ scp v0.1.18.tar.gz $TARGET:/home/user/download/nginx-module-vts-0.1.18


- 설치 인스턴스에서 실행

$ yum install gcc gcc-c++
$ mkdir /home/user/apps/nginx
$ cd download
$ tar -xvzf nginx-1.20.2.tar.gz
$ tar -xvzf zlib-1.2.11.tar.gz
$ tar -xvzf openssl-1.1.1l.tar.gz
$ tar -xvzf openssl-3.0.0.tar.gz
$ tar -xvzf headers-more-nginx-module-0.33.tar.gz
$ tar -xvzf nginx-module-vts-0.1.18.tar.gz

$ cd nginx-1.20.2
$ ./configure --prefix=/home/user/apps/nginx --with-http_stub_status_module 
--with-http_ssl_module --with-http_v2_module --with-http_secure_link_module 
--with-http_realip_module --with-stream --with-mail --with-mail_ssl_module 
--with-openssl-opt=enable-tlsext --with-openssl=/home/user/download/openssl-1.1.1l 
--add-module=/home/user/download/headers-more-nginx-module-0.33 
--add-module=/home/user/download/nginx-module-vts-0.1.18
$ make
에러발생
***** Unsupported options: enable-tlsext
이 에러는 삭제된 옵션 이기 때문에 발생 합니다. (openssl 0.9.8j 이후 부터는 기본 활성화 되어 있습니다.)

$ ./configure --prefix=/home/user/apps/nginx --with-http_stub_status_module 
--with-http_ssl_module --with-http_v2_module --with-http_secure_link_module 
--with-http_realip_module --with-stream --with-mail --with-mail_ssl_module 
--with-openssl=/home/user/download/openssl-1.1.1l 
--add-module=/home/user/download/headers-more-nginx-module-0.33 
--add-module=/home/user/download/nginx-module-vts-0.1.18
$ make
$ make install

 

:

[Nginx] nginx + ldap 연동

ITWeb/개발일반 2019. 9. 19. 14:38

$ nginx -V
nginx version: nginx/1.14.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
built with OpenSSL 1.1.0h  27 Mar 2018
TLS SNI support enabled
configure arguments: --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/run/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-pcre=../pcre-8.42 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.1.0h --with-http_ssl_module --add-module=../nginx-auth-ldap --user=nginx --group=nginx

 

다운로드)

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

 

소스코드 Clone)

$ git clone https://github.com/kvspb/nginx-auth-ldap.git

$ tar -xvzf nginx-1.14.2.tar.gz
$ cd nginx-1.14.2
$ ./configure --with-compat --add-dynamic-module=../nginx-auth-ldap
$ make modules

$ cp objs/ngx_http_auth_ldap_module.so /etc/nginx/modules/

$ vi /etc/nginx/nginx.conf

...중략...

load_module /etc/nginx/modules/ngx_http_auth_ldap_module.so;

...중략...

 

http {
    auth_ldap_cache_enabled on;
    auth_ldap_cache_expiration_time 10000;
    auth_ldap_cache_size 1000;

    ldap_server ipa {
         url "ldap://.................";
         binddn "uid=LDAPUSER,cn=users,cn=accounts,dc=..............,dc=kr";
         binddn_passwd "LDAPPASSWORD";
         group_attribute uniquemember;
         group_attribute_is_dn on;
         require valid_user;
    }

    server {
           location / {
           auth_ldap "Enter AD credentials e.g. 'your ID'";
           auth_ldap_servers ipa;
           root   html;
           index  index.html index.htm;
            }
    }
}

 

$ nginx -t
nginx: [emerg] module "ngx_http_auth_ldap_module" is already loaded in /etc/nginx/nginx.conf:8
nginx: configuration file /etc/nginx/nginx.conf test failed
nginx 재시작

 

-- load_module /etc/nginx/modules/ngx_http_auth_ldap_module.so; 부분 제거


$ systemctl restart nginx

 

참고)
- nginx dynamic module build
https://www.nginx.com/blog/compiling-dynamic-modules-nginx-plus/

 

이걸 어디서 사용하냐면 kibana + ldap 연동 시 사용하면 좋습니다. (ldap 연동은 elastic stack basic 이 아니라서....)

기고해 주신 보스웰 고맙습니다.

:

[AWS] ELB + http to https + Nginx 설정

ITWeb/개발일반 2017. 2. 2. 10:12

요즘 대부분의 서비스들이 http 를 제거 하고 https 로 서비스 하기 시작했습니다.

AWS 에서 제공하는 SSL 을 이용해서 ELB 에 구성하신 분들의 경우 대부분 아래와 같이 되어 있을 것 같은데요.


http://service    -> elb:80   -> ec2:80

https://service  -> elb:443  -> ec2:80


이와 같이 되어 있다 보니 개별 ec2 에서는 모두 listen 80 만 하게 됩니다.

그래서 client 에서 http 로 들어 왔는지 https 로 들어 왔는지 확인이 필요 한데요.

이 경우 아래와 같은 변수들을 활용해서 설정을 하시면 됩니다.


[참고문서]

http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/x-forwarded-headers.html


[X-Forwarded Headers]

X-Forwarded-For

X-Forwarded-Proto

X-Forwarded-Port


[Nginx 설정]

server {

  listen       80;

  server_name  localhost;


  if ($http_x_forwarded_proto = 'http') {

    return 301 https://$server_name$request_uri;

  }

}


참고 용이니 실 서비스에 적용 시 충분한 테스트 후 적용하시기 바랍니다.

:

[Nginx] osx 에 nginx 설치 하기 - brew install

ITWeb/개발일반 2016. 11. 23. 10:02

mac osx 에 설치 할 일이 있어서 작성해 봅니다.


$ sudo chown -R '사용자계정' /usr/local/lib/pkgconfig

$ brew install pcre

$ brew link --overwrite pcre

$ brew update

$ sudo chown -R '사용자계정' /usr/local

$ brew install nginx

$ sudo chown root:wheel /usr/local


'사용자계정' 에는 user account 넣어 주시면 됩니다.

예를 들어 henry 라는 계정을 사용하시면)

$ sudo chown -R henry /usr/local/lib/pkgconfig


저는 설치 하다 몇 가지 에러가 발생을 해서 위 순서대로 구성을 하였습니다.

아래는 발생한 에러 입니다.


Error case 1)

Error: The `brew link` step did not complete successfully

The formula built, but is not symlinked into /usr/local

Could not symlink lib/pkgconfig/libpcre.pc

/usr/local/lib/pkgconfig is not writable.


Error case 2)

mkdir: /usr/local/var/run: Permission denied

make[1]: *** [install] Error 1

make: *** [install] Error 2


READ THIS: https://git.io/brew-troubleshooting


/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open-uri.rb:353:in `open_http': 422 Unprocessable Entity (GitHub::Error)

Validation Failed


Error case 3)

Error: The /usr/local directory is not writable.

Even if this directory was writable when you installed Homebrew, other

software may change permissions on this directory. For example, upgrading

to OS X El Capitan has been known to do this. Some versions of the

"InstantOn" component of Airfoil or running Cocktail cleanup/optimizations

are known to do this as well.


You should probably change the ownership and permissions of /usr/local

back to your user account.

  sudo chown -R $(whoami):admin /usr/local


: