Intro
Kafka Cluster
incoming message
- without kafka client library support
(e.g. Android or IOS app, IOT devices, …)
- send message using Rest APIs
https
- 443 port : web page (for test)
- 8443 port : rest service
사설 인증서 생성
[root@master ~]# mkdir /root/ssl/
[root@master ~]# cd ssl
[root@master ssl]# openssl req -x509 -days 358000 -nodes -newkey rsa:2048
> -keyout /root/ssl/nginx-ssl.key -out /root/ssl/nginx-ssl.crt
Generating a 2048 bit RSA private key
........+++
.....................................................................................................+++
writing new private key to '/root/ssl/nginx-ssl.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:KR
State or Province Name (full name) []:Seoul
Locality Name (eg, city) [Default City]:
Organization Name (eg, company) [Default Company Ltd]:Kopo
Organizational Unit Name (eg, section) []:smart finance
Common Name (eg, your name or your server's hostname) []:devfmd
Email Address []:a@a.com
인증서 만료일 : 미지정시 30일, 테스트용으로 몇 백년 지정
openssl req -x509 -days 358000 -nodes -newkey rsa:2048
-keyout /root/ssl/nginx-ssl.key -out /root/ssl/nginx-ssl.crt
도메인명 일치해야 함(불일치시 클라이언트에서 인증서 오류발생으로 접속 불가)
Nginx 디렉토리로 인증서 카피
인증서 복사를 mv가 아닌 cp명령으로 수행해야 하는 이유 : https://stackoverflow.com/questions/37994513/
결과 확인
http 접속시 https 자동 이동
certobot 인증서 발급시 nginx default 파일에
https 관련 코드와 301 리다이렉션 코드
자동으로 추가됨
Certbot 인증서 자동갱신 크론탭 등록
• certbot renew --dry-run
• /etc/cron.d/에 크론탭 자동 등록
고정IP, 도메인이 없는 경우
• ngrok 또는 localtunnel 적용 고려(임시방편)
ngrok : 하나의 서버에 대해 무료, 서버 재시작시 도메인 변경됨
localtunnel : 도메인명.loca.lt 형태로 고정되나, 중계서버 간헐적 불안정
VS
https://localtunnel.github.io/www/
https://ngrok.com/
참고자료
• CentOS에서 Nginx, Certbot 설치하고 인증서 적용하기
https://stove99.github.io/linux/2019/08/27/install-lets-encrypt-to-nginx-in-centos/
• Root CA 인증서 발급 및 적용 절차
https://www.sslcert.co.kr/guides/NGINX-SSL-Certificate-Install
https://velog.io/@twkim8548/Nginx%EC%97%90%EC%84%9C-SSL-%EC%A0%81%EC%9A%A9%ED%95%B4%EC%84%9C-Https-%EB%A1%9C-
%EC%A0%91%EC%86%8D-%EB%90%98%EA%B2%8C-%ED%95%B4%EB%B3%BC%EA%B9%8C
Notas del editor
인증서 만료는 디폴트 30일 : https://serverfault.com/questions/920461/why-openssl-ignore-days-for-expiration-date-for-self-signed-certificate
openssl pkcs12 -export -in nginx-ssl.crt -inkey nginx-ssl.key -out nginx-ssl.pfx
Enter Export Password:
Verifying - Enter Export Password:
curl --location --request GET 'https://devfmd:8443/api' --header 'Content-Type: application/json'-v --cacert nginx-ssl.crt
필요시 {nginx home directory}/nginx.conf에서 user root; 설정
https://jamie95.tistory.com/184
/etc/nginx/sites-available/default 파일 하단에서 301 리다이렉션 부분 주석처리 후,
if문만 상단 80 섹션으로 이동시킨다.
(이렇게 하면 80 을 443 으로 이동시키면서 http를 사용하는 다른 서비스 유지 가능)
server {
listen 80 default_server;
listen [::]:80 default_server;
if ($host = smart.wonyong.net) {
return 301 https://$host$request_uri;
}