'ITWeb/개발일반'에 해당되는 글 489건

  1. 2020.02.26 [AWS] ssh tunneling on ec2
  2. 2020.02.24 [Network] NAT IP 확인 방법
  3. 2020.02.05 [보안] CSR (Certificate Signing Request) + CA (Certificate Authority)
  4. 2020.02.04 [CIDR] 표기법에 대한 짧은 이해.
  5. 2020.01.17 [Python] MacOS에서 awscli 설치 오류
  6. 2019.11.05 [httpcomponents-client] CloseableHttpClient - Accept Encoding
  7. 2019.10.08 [Spring] Disable Spring Data Auto Configuration
  8. 2019.09.20 [Spring] Springboot + Thymeleaf 설정 시 주의.
  9. 2019.09.19 [Nginx] nginx + ldap 연동
  10. 2019.09.18 [SpringBoot] Project Starter

[AWS] ssh tunneling on ec2

ITWeb/개발일반 2020. 2. 26. 08:33

AWS Linux 로 EC2 생성을 했을 경우)

$ ssh -i key.pem ec2-user@hostname

 

AWS  Ubuntu 로 EC2 생성을 했을 경우)

$ ssh -i key.pem ubuntu@hostname

:

[Network] NAT IP 확인 방법

ITWeb/개발일반 2020. 2. 24. 19:50

Public Cloud 를 사용 하다 보면 Network ACL 설정이나 Security Group 설정에서 Inbound 제한을 걸어야 할 때가 있습니다.

그래서 사무실 Outbound 용 NAT IP 가 어떻게 되는지 확인이 필요 하게 되는데요.

누가 알려 주지도 않고 관련 정보가 없을 경우 다 알아서 해야겠죠.

기억력을 돕기 위해 구글링 한 내용 작성해 봤습니다. 

 

[What Is My IP Address? - ifconfig.me]

https://ifconfig.me/

 

$ curl bot.whatismyipaddress.com
$ curl icanhazip.com
$ curl ipv4.icanhazip.com
$ curl http://ipecho.net/plain
$ curl ifconfig.me

:

[보안] CSR (Certificate Signing Request) + CA (Certificate Authority)

ITWeb/개발일반 2020. 2. 5. 10:48

(아는 것도 다시 보자)

인증서 발급을 받기 위해 Private key 와 Public key 를 생성해서 인증서 생성 요청을 하는 방식 입니다.

CSR 에는 개인정보나 도메인정보 그리고 Public key 가 포함 되어서 파일이 생성 됩니다.

 

https://en.wikipedia.org/wiki/Certificate_signing_request

 

Certificate signing request - Wikipedia

In public key infrastructure (PKI) systems, a certificate signing request (also CSR or certification request) is a message sent from an applicant to a certificate authority in order to apply for a digital identity certificate. It usually contains the publi

en.wikipedia.org

CSR 을 만들었으면 CA 기관에 전달 해서 인증서 발급을 받으시면 되겠습니다.

 

https://en.wikipedia.org/wiki/Certificate_authority

 

Certificate authority - Wikipedia

In cryptography, a certificate authority or certification authority (CA) is an entity that issues digital certificates. A digital certificate certifies the ownership of a public key by the named subject of the certificate. This allows others (relying parti

en.wikipedia.org

 

:

[CIDR] 표기법에 대한 짧은 이해.

ITWeb/개발일반 2020. 2. 4. 15:37

가끔 가다 정신 줄 놓을 때가 있는데, 바로 이런걸 가지고 이야기 하나 봅니다.

 

AAA.BBB.CCC.DDD/N

 

AAA : 2^8 (11111111 : 8bits : 256)

BBB : 2^8 (11111111 : 8bits : 256)

CCC : 2^8 (11111111 : 8bits : 256)

DDD : 2^8 (11111111 : 8bits : 256)

N 은 좌측 bits 에 대한 합입니다.

    - 32 : AAA.BBB.CCC.DDD 가 고유 IP ( Case 1 )

    - 24 : AAA.BBB.CCC 까지 변경 없음 ( Case 2 )

    - 16 : AAA.BBB 까지 변경 없음 ( Case 3 )

    - 8 : AAA 까지 변경 없음 ( Case 4 )

 

Case 1)

192.0.0.0/32

이렇게 표기 하면 192.0.0.0 이 바로 IP 가 됩니다.

 

Case 2)

192.0.0.0/24

이렇게 표기 하면 192.0.0.0 ~ 192.0.0.255 까지 IP 가 됩니다.

 

Case 3)

192.0.0.0/16

이렇게 표기 하면 192.0.0.0 ~ 192.0.255.255 까지 IP 가 됩니다.

 

Case 4)

192.0.0.0/8

이렇게 표기 하면 192.0.0.0 ~ 192.255.255.255 까지 IP 가 됩니다.

 

구글링 하시면 CIDR 계산기 정보들이 많이 나오니 한번 돌려 보셔도 좋습니다.

:

[Python] MacOS에서 awscli 설치 오류

ITWeb/개발일반 2020. 1. 17. 13:32

보던 책이 있어서 그냥 한번 따라 해봤는데 에러가 발생 해서 수정 하는 과정을 그냥 기록해 봤습니다.

 

homebrew installation)
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

python installation for awscli)
$ brew install python

- python 3.4 이상 설치
https://www.python.org/doc/sunset-python-2/

pip installation)
$ sudo easy_install pip

awscli installation)
$ sudo pip install awscli

- pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. 에러 발생
$ python3 --version
Python 3.8.1

$ python --version
Python 3.6.6

$ rm -rf 로 3.6.6 을 삭제
$ brew uninstall python
https://www.python.org/downloads/ 에서 pkg 파일로 다운로드 후 재 설치
$ sudo pip3 install awscli
$ pip3 install --upgrade pip
$ mkdir -p .pyenv/shims
$ ln -s /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 python

 

$ pip --version
pip 19.3.1 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)

$ pip3 --version
pip 19.3.1 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)

:

[httpcomponents-client] CloseableHttpClient - Accept Encoding

ITWeb/개발일반 2019. 11. 5. 10:53

RESTful 통신을 많이 하면서 httpclient 를 활용이 높습니다.

제가 사용하고 있는 httpclient 중에 CloseableHttpClient 가 있는데 이 클라이언트의 경우 Accept Encoding 설정이 기본적으로 enable 되어 있습니다.

그래서 기억력을 돕기 위해 또 기록해 봅니다.

 

참고 이전 글)

https://jjeong.tistory.com/1369

 

HttpClientBuilder.java)

public CloseableHttpClient build() {
... 중략 ...
            if (!contentCompressionDisabled) {
                if (contentDecoderMap != null) {
                    final List<String> encodings = new ArrayList<String>(contentDecoderMap.keySet());
                    Collections.sort(encodings);
                    b.add(new RequestAcceptEncoding(encodings));
                } else {
                    b.add(new RequestAcceptEncoding());
                }
            }
            if (!authCachingDisabled) {
                b.add(new RequestAuthCache());
            }
            if (!cookieManagementDisabled) {
                b.add(new ResponseProcessCookies());
            }
            if (!contentCompressionDisabled) {
                if (contentDecoderMap != null) {
                    final RegistryBuilder<InputStreamFactory> b2 = RegistryBuilder.create();
                    for (final Map.Entry<String, InputStreamFactory> entry: contentDecoderMap.entrySet()) {
                        b2.register(entry.getKey(), entry.getValue());
                    }
                    b.add(new ResponseContentEncoding(b2.build()));
                } else {
                    b.add(new ResponseContentEncoding());
                }
            }
... 중략 ...
    }

RequestAcceptEndocing.java)

...중략...
    public RequestAcceptEncoding(final List<String> encodings) {
        if (encodings != null && !encodings.isEmpty()) {
            final StringBuilder buf = new StringBuilder();
            for (int i = 0; i < encodings.size(); i++) {
                if (i > 0) {
                    buf.append(",");
                }
                buf.append(encodings.get(i));
            }
            this.acceptEncoding = buf.toString();
        } else {
            this.acceptEncoding = "gzip,deflate";
        }
    }
...중략...

요청 하는 Client 에서 Server 로 콘텐츠를 압축해서 전송해줘 해야 압축해서 전송을 해주게 되는 내용입니다.

아무리 서버에서 압축 전송이 가능 하도록 설정을 했어도 요청을 하지 않으면 그냥 plain/text 로 넘어 올 수 밖에 없습니다.

 

참고문서)

https://developer.mozilla.org/ko/docs/Web/HTTP/Headers/Accept-Encoding

 

Accept-Encoding

Accept-Encoding 요청 HTTP 헤더는, 보통 압축 알고리즘인, 클라이언트가 이해 가능한 컨텐츠 인코딩이 무엇인지를 알려줍니다. 컨텐츠 협상을 사용하여, 서버는 제안된 내용 중 하나를 선택하고 사용하며 Content-Encoding 응답 헤더를 이용해 선택된 것을 클라이언트에게  알려줍니다.

developer.mozilla.org

 

:

[Spring] Disable Spring Data Auto Configuration

ITWeb/개발일반 2019. 10. 8. 09:53

단순 Spring Batch Job, Step, Reader, Processor, Writer 테스트만 하려고 하다 아래와 같은 에러가 발생을 해서 그냥 disable 하고 테스트 했습니다.

 

[Error Message]

***************************
APPLICATION FAILED TO START
***************************

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class


Action:

Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

 

[application.properties]

spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration, \

org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration, \

org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration

:

[Spring] Springboot + Thymeleaf 설정 시 주의.

ITWeb/개발일반 2019. 9. 20. 13:58

springboot 에서 thymeleaf 사용 시 applicaiton.properties 내 주의 사항 정도 입니다.

 

기본 설정은 아래와 같습니다.

 

spring.thymeleaf.cache=true
spring.thymeleaf.check-template=true
spring.thymeleaf.check-template-location=true
spring.thymeleaf.enabled=true
spring.thymeleaf.enable-spring-el-compiler=false
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.excluded-view-names=
spring.thymeleaf.mode=HTML
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.reactive.chunked-mode-view-names=
spring.thymeleaf.reactive.full-mode-view-names=
spring.thymeleaf.reactive.max-chunk-size=0B
spring.thymeleaf.reactive.media-types=
spring.thymeleaf.render-hidden-markers-before-checkboxes=false
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.servlet.produce-partial-output-while-processing=true
spring.thymeleaf.suffix=.html
spring.thymeleaf.template-resolver-order=0
spring.thymeleaf.view-names=

 

이 설정 값들을 넣어 주지 않으셔도 기본 동작에는 문제가 없으나 설정 최적화와 이해를 위해서는 각각의 설정이 어떤 의미를 가지는지 아는게 중요 합니다.

 

viewResolver 관련해서 주의 점은!!

spring.thymeleaf.view-names# Comma-separated list of view names (patterns allowed) that can be resolved.

이 설정을 제거 하시거나 등록을 해주셔야 한다는 것입니다.

 

그냥 저렇게 empty value 로 놔두시면 viewResolver 오류가 발생을 하게 됩니다.

주석에 나와 있는 설명 처럼 목록으로 넣어 주시거나 패턴으로 잡아 주시면 되겠습니다.

:

[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 이 아니라서....)

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

:

[SpringBoot] Project Starter

ITWeb/개발일반 2019. 9. 18. 10:10

시작 하기에 앞서 한번 읽어 보고 하면 좋은 링크 스크랩.

 

https://start.spring.io
https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/
https://docs.gradle.org/current/userguide/java_library_plugin.html

 

저 문서들을 읽고 나니 왜 스프링부트가 대세가 되었는지 알겠내요.

: