SlideShare a Scribd company logo
1 of 28
Intro
http/https request
80, 443 port
response
Ngrok agent
NAT / Firewall
외부와 양방향 통신 가능한 고정IP이 없는 경우에
Ngrok의 터널링 기능을 활용하면, 운영환경을 개발서버에서 시뮬레이션 할 수 있음
centos7
Nginx 설치
• yum install을 위한 nginx.repo 파일 생성 및 편집
# vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
# yum install -y nginx
Nginx 구동
• 서비스 구동 및 접속 확인
# systemctl start nginx
# systemctl enable nginx
Ngrok 설치
https://ngrok.com/download
ftp로 서버에 업로드 후 압축해제
# tar xvzf ./ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin
Ngrok 구동
• 서비스 구동 및 접속 확인
# ngrok http 80
이 주소로 접속하면 Ngrok 중계서버가 나의 서버를 연결해 준다는 의미
이 주소는 리부팅 등 실행시마다 변동됨 (무료 계정)
또한, 8시간 정도만 주소가 유지됨 (실행 이후 주소 고정을 원할 경우 ‘인증토큰’을 추가해줘야 함  다음 장)
Ngrok 인증 토큰 추가
• Ngrok 회원 가입 필요
• 토큰 추가는 무료
• 무료 계정은 분당 요청 : 분당 약 40회까지 허용
유료 계정은 분당 약 120회
회원 가입 후 ‘Your Authtoken’ 메뉴 이동하여 토큰 확인
# ngrok config add-authtoken “인증 토큰”
Ngrok 서비스 중지 후 위 명령어 실행  Ngrok 서비스 실행
Ngrok 인증 토큰 추가
인증 토큰 추가 후, 재시작한 Ngrok 서비스에서
변경된 접속 주소 확인 후, 해당 주소로 접속
‘Visit Site’ 버튼 클릭
외부 도메인 연결 + https 적용
준비사항 : 도메인 준비
예> 가비아 이벤트용 도메인 1년에 2,000원
[참고]
도메인 등록 및 CNAME 설정
• 도메인 등록 및 CNAME 설정 후 nslookup으로 등록여부 확인
- 최초 도메인 등록時 DNS전파에 일정 시간 소요 (0분~00분)
certbot 설치
• Let’s Encrypt 인증서 발급 권장 도구
# yum install epel-release
# yum install certbot python2-certbot-nginx
# yum install certbot
certbot을 활용한 인증서 발급
• certbot certonly -d [도메인명] --manual --preferred-challenges dns
# certbot certonly -d server.kopo.online --manual --preferred-challenges dns
거의 모든 스텝을 ‘Y’로 입력 진행하다가,
우측의 DNS TXT 필드 입력 문구가 나오면
DNS관리에서 입력 및 저장을 먼저 완료하고
엔터를 입력해야 정상 진행됨
인증서 위치 확인
• /etc/letsencrypt/live/[도메인명]
nginx에 인증서 설정 및 ssl 서비스 등록
• vi /etc/nginx/conf.d/default.conf
• nginx -s reload
server{
listen 443 ssl;
server_name server.kopo.online;
root /usr/share/nginx/html;
index index.html;
ssl_certificate /etc/letsencrypt/live/server.kopo.online/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/server.kopo.online/privkey.pem;
}
로컬에서 자체 테스트
로컬 개발서버에서 hosts파일을 임시로 편집하여 로컬 브라우저로 접속하였을때 정상여부를 확인
정상이면 hosts파일은 원상복구
인증서 자동 갱신 크론탭 등록
# crontab -e
0 0 1 * * root systemctl stop nginx && certbot renew -q && systemctl start nginx
매달 1일에 인증서 갱신 시도
외부 도메인과 Ngrok 연계
• server.kopo.online 도메인을 Ngrok으로 연계하기 위해서는
유료 계정을 사용해야 한다.
외부 도메인과 Ngrok 연계
• 유료 계정 가입 후 아래 링크로 이동
25$/month, 1년 단위 계약시 20$/month
• https://dashboard.ngrok.com/cloud-edge/domains
외부 도메인과 Ngrok 연계
외부 도메인과 Ngrok 연계
• Ngrok에서 도메인 추가하기 전에 기등록한 CNAME은 삭제해야 함
(미삭제시 Ngrok 에서 에러 발생)
server.kopo.online 입력
외부 도메인과 Ngrok 연계
외부 도메인과 Ngrok 연계
DNS 관리화면에 입력할 내용이므로
잠시 화면 정지
외부 도메인과 Ngrok 연계
① 주어진 정보를 DNS 관리화면에 입력 및 저장
② 저장 후 Ngrok 화면에서 다음 단계를 진행하면
전파된 DNS 정보를 조회하여 정상여부를 출력한다.
외부 도메인과 Ngrok 연계
• start tunnel 버튼을 클릭하면 아래와 같은 실행 명령을 제공
• 명령줄을 복사하여 서버에서 실행
외부 도메인과 Ngrok 연계
• 실행 결과 확인
외부 도메인과 Ngrok 연계
• 서버에서 /etc/hosts 편집
외부 도메인과 Ngrok 연계
• 서버에서 /etc/hosts 파일에 server.kopo.online을 추가해야 하는 이유
상기 내용 미반영시,
서버 외부 브라우저 접속시 인증서 불일치 경고 발생(서버내에 있는 브라우저는 정상 접속)
추정 사유> server.kopo.online 접속 -> ngrok 중계, ngrok 인증서 교환 -> 로컬 서버 응답 ->
응답시 server.kopo.online을 참조하는데 위와 같이 설정하지 않으면 다시 ngrok 서버 및 해당
인증서로 연계하여 접속 주소와 인증서의 불일치가 발생하게 됨 (상기 그림)
[참고] Ngrok을 이용한 터미널 연결
• ngrok tcp 22

More Related Content

What's hot

Why Docker
Why DockerWhy Docker
Why Docker
dotCloud
 

What's hot (20)

Ansible, best practices
Ansible, best practicesAnsible, best practices
Ansible, best practices
 
Monitoring Kubernetes with Prometheus
Monitoring Kubernetes with PrometheusMonitoring Kubernetes with Prometheus
Monitoring Kubernetes with Prometheus
 
NGINX: Basics and Best Practices
NGINX: Basics and Best PracticesNGINX: Basics and Best Practices
NGINX: Basics and Best Practices
 
High Availability Content Caching with NGINX
High Availability Content Caching with NGINXHigh Availability Content Caching with NGINX
High Availability Content Caching with NGINX
 
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
Nginx A High Performance Load Balancer, Web Server & Reverse ProxyNginx A High Performance Load Balancer, Web Server & Reverse Proxy
Nginx A High Performance Load Balancer, Web Server & Reverse Proxy
 
HCL Sametime 12.0 – Converting from native Domino Directory to LDAP and Migra...
HCL Sametime 12.0 – Converting from native Domino Directory to LDAP and Migra...HCL Sametime 12.0 – Converting from native Domino Directory to LDAP and Migra...
HCL Sametime 12.0 – Converting from native Domino Directory to LDAP and Migra...
 
Vault - Secret and Key Management
Vault - Secret and Key ManagementVault - Secret and Key Management
Vault - Secret and Key Management
 
Intro to Telegraf
Intro to TelegrafIntro to Telegraf
Intro to Telegraf
 
OpenStack vs VMware vCloud
OpenStack vs VMware vCloudOpenStack vs VMware vCloud
OpenStack vs VMware vCloud
 
Enable Domino Data Access Services (DAS)
Enable Domino Data Access Services (DAS)Enable Domino Data Access Services (DAS)
Enable Domino Data Access Services (DAS)
 
Continuous Integration & Continuous Delivery
Continuous Integration & Continuous DeliveryContinuous Integration & Continuous Delivery
Continuous Integration & Continuous Delivery
 
Getting Started: Intro to Telegraf - July 2021
Getting Started: Intro to Telegraf - July 2021Getting Started: Intro to Telegraf - July 2021
Getting Started: Intro to Telegraf - July 2021
 
Getting Started Monitoring with Prometheus and Grafana
Getting Started Monitoring with Prometheus and GrafanaGetting Started Monitoring with Prometheus and Grafana
Getting Started Monitoring with Prometheus and Grafana
 
Prometheus and Grafana
Prometheus and GrafanaPrometheus and Grafana
Prometheus and Grafana
 
Kubernetes Probes (Liveness, Readyness, Startup) Introduction
Kubernetes Probes (Liveness, Readyness, Startup) IntroductionKubernetes Probes (Liveness, Readyness, Startup) Introduction
Kubernetes Probes (Liveness, Readyness, Startup) Introduction
 
Why Docker
Why DockerWhy Docker
Why Docker
 
Rapport installation round cube centos 7
Rapport installation round cube centos 7Rapport installation round cube centos 7
Rapport installation round cube centos 7
 
Server monitoring using grafana and prometheus
Server monitoring using grafana and prometheusServer monitoring using grafana and prometheus
Server monitoring using grafana and prometheus
 
MeetUp Monitoring with Prometheus and Grafana (September 2018)
MeetUp Monitoring with Prometheus and Grafana (September 2018)MeetUp Monitoring with Prometheus and Grafana (September 2018)
MeetUp Monitoring with Prometheus and Grafana (September 2018)
 
TC Flower Offload
TC Flower OffloadTC Flower Offload
TC Flower Offload
 

Similar to Ngrok을 이용한 Nginx Https 적용하기.pptx

JCO 11th 클라우드 환경에서 Java EE 운영 환경 구축하기
JCO 11th 클라우드 환경에서 Java EE 운영 환경 구축하기JCO 11th 클라우드 환경에서 Java EE 운영 환경 구축하기
JCO 11th 클라우드 환경에서 Java EE 운영 환경 구축하기
Ted Won
 

Similar to Ngrok을 이용한 Nginx Https 적용하기.pptx (20)

Nginx Https 적용하기.pptx
Nginx Https 적용하기.pptxNginx Https 적용하기.pptx
Nginx Https 적용하기.pptx
 
Nginx basic configurations
Nginx basic configurationsNginx basic configurations
Nginx basic configurations
 
[오픈소스컨설팅]Nginx 1.2.7 설치가이드__v1
[오픈소스컨설팅]Nginx 1.2.7 설치가이드__v1[오픈소스컨설팅]Nginx 1.2.7 설치가이드__v1
[오픈소스컨설팅]Nginx 1.2.7 설치가이드__v1
 
Kafka slideshare
Kafka   slideshareKafka   slideshare
Kafka slideshare
 
Deploying Hyperledger Fabric on Kubernetes.pptx
Deploying Hyperledger Fabric on Kubernetes.pptxDeploying Hyperledger Fabric on Kubernetes.pptx
Deploying Hyperledger Fabric on Kubernetes.pptx
 
[오픈소스컨설팅]Nginx jboss 연동가이드__v1
[오픈소스컨설팅]Nginx jboss 연동가이드__v1[오픈소스컨설팅]Nginx jboss 연동가이드__v1
[오픈소스컨설팅]Nginx jboss 연동가이드__v1
 
리스펙토링 세미나 - 나만의 카카오 챗봇 만들기
리스펙토링 세미나 - 나만의 카카오 챗봇 만들기리스펙토링 세미나 - 나만의 카카오 챗봇 만들기
리스펙토링 세미나 - 나만의 카카오 챗봇 만들기
 
nexus helm 설치, docker/helm repo 설정과 예제
nexus helm 설치, docker/helm repo 설정과 예제nexus helm 설치, docker/helm repo 설정과 예제
nexus helm 설치, docker/helm repo 설정과 예제
 
Internship backend
Internship backendInternship backend
Internship backend
 
Udamp3 django apache-my_sql_python3_ubuntu14.04-v11
Udamp3 django apache-my_sql_python3_ubuntu14.04-v11Udamp3 django apache-my_sql_python3_ubuntu14.04-v11
Udamp3 django apache-my_sql_python3_ubuntu14.04-v11
 
[Ansible] Solution Guide V0.4_20181204.pdf
[Ansible] Solution Guide V0.4_20181204.pdf[Ansible] Solution Guide V0.4_20181204.pdf
[Ansible] Solution Guide V0.4_20181204.pdf
 
JCO 11th 클라우드 환경에서 Java EE 운영 환경 구축하기
JCO 11th 클라우드 환경에서 Java EE 운영 환경 구축하기JCO 11th 클라우드 환경에서 Java EE 운영 환경 구축하기
JCO 11th 클라우드 환경에서 Java EE 운영 환경 구축하기
 
리눅스서버세팅-김태호
리눅스서버세팅-김태호리눅스서버세팅-김태호
리눅스서버세팅-김태호
 
1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기
1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기
1908 Hyperledger Fabric 소개 및 첫 네트워크 구축하기
 
Tensorflow service & Machine Learning
Tensorflow service & Machine LearningTensorflow service & Machine Learning
Tensorflow service & Machine Learning
 
docker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
docker on GCE ( JIRA & Confluence ) - GDG Korea Clouddocker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
docker on GCE ( JIRA & Confluence ) - GDG Korea Cloud
 
PCF Installation Guide
PCF Installation GuidePCF Installation Guide
PCF Installation Guide
 
[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기
[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기
[NDC18] 만들고 붓고 부수고 - 〈야생의 땅: 듀랑고〉 서버 관리 배포 이야기
 
Enable the Docker Remote API with Secure Connection! (안전하게 도커 원격 작업하기)
Enable the Docker Remote API with Secure Connection! (안전하게 도커 원격 작업하기)Enable the Docker Remote API with Secure Connection! (안전하게 도커 원격 작업하기)
Enable the Docker Remote API with Secure Connection! (안전하게 도커 원격 작업하기)
 
Hadoop security DeView 2014
Hadoop security DeView 2014Hadoop security DeView 2014
Hadoop security DeView 2014
 

More from wonyong hwang

More from wonyong hwang (18)

Hyperledger Explorer.pptx
Hyperledger Explorer.pptxHyperledger Explorer.pptx
Hyperledger Explorer.pptx
 
하이퍼레저 페이지 단위 블록 조회
하이퍼레저 페이지 단위 블록 조회하이퍼레저 페이지 단위 블록 조회
하이퍼레저 페이지 단위 블록 조회
 
토큰 증권 개요.pptx
토큰 증권 개요.pptx토큰 증권 개요.pptx
토큰 증권 개요.pptx
 
Vue.js 기초 실습.pptx
Vue.js 기초 실습.pptxVue.js 기초 실습.pptx
Vue.js 기초 실습.pptx
 
k8s practice 2023.pptx
k8s practice 2023.pptxk8s practice 2023.pptx
k8s practice 2023.pptx
 
HyperLedger Fabric V2.5.pdf
HyperLedger Fabric V2.5.pdfHyperLedger Fabric V2.5.pdf
HyperLedger Fabric V2.5.pdf
 
Kafka JDBC Connect Guide(Postgres Sink).pptx
Kafka JDBC Connect Guide(Postgres Sink).pptxKafka JDBC Connect Guide(Postgres Sink).pptx
Kafka JDBC Connect Guide(Postgres Sink).pptx
 
Nginx Reverse Proxy with Kafka.pptx
Nginx Reverse Proxy with Kafka.pptxNginx Reverse Proxy with Kafka.pptx
Nginx Reverse Proxy with Kafka.pptx
 
Kafka Rest.pptx
Kafka Rest.pptxKafka Rest.pptx
Kafka Rest.pptx
 
주가 정보 다루기.pdf
주가 정보 다루기.pdf주가 정보 다루기.pdf
주가 정보 다루기.pdf
 
App development with quasar (pdf)
App development with quasar (pdf)App development with quasar (pdf)
App development with quasar (pdf)
 
kubernetes practice
kubernetes practicekubernetes practice
kubernetes practice
 
Hyperledger Fabric practice (v2.0)
Hyperledger Fabric practice (v2.0) Hyperledger Fabric practice (v2.0)
Hyperledger Fabric practice (v2.0)
 
Docker practice
Docker practiceDocker practice
Docker practice
 
Hyperledger fabric practice(pdf)
Hyperledger fabric practice(pdf)Hyperledger fabric practice(pdf)
Hyperledger fabric practice(pdf)
 
Hyperledger composer
Hyperledger composerHyperledger composer
Hyperledger composer
 
BlockChain implementation by python
BlockChain implementation by pythonBlockChain implementation by python
BlockChain implementation by python
 
Block chain introduction slideshare
Block chain introduction   slideshareBlock chain introduction   slideshare
Block chain introduction slideshare
 

Ngrok을 이용한 Nginx Https 적용하기.pptx

  • 1.
  • 2. Intro http/https request 80, 443 port response Ngrok agent NAT / Firewall 외부와 양방향 통신 가능한 고정IP이 없는 경우에 Ngrok의 터널링 기능을 활용하면, 운영환경을 개발서버에서 시뮬레이션 할 수 있음 centos7
  • 3. Nginx 설치 • yum install을 위한 nginx.repo 파일 생성 및 편집 # vi /etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1 # yum install -y nginx
  • 4. Nginx 구동 • 서비스 구동 및 접속 확인 # systemctl start nginx # systemctl enable nginx
  • 5. Ngrok 설치 https://ngrok.com/download ftp로 서버에 업로드 후 압축해제 # tar xvzf ./ngrok-v3-stable-linux-amd64.tgz -C /usr/local/bin
  • 6. Ngrok 구동 • 서비스 구동 및 접속 확인 # ngrok http 80 이 주소로 접속하면 Ngrok 중계서버가 나의 서버를 연결해 준다는 의미 이 주소는 리부팅 등 실행시마다 변동됨 (무료 계정) 또한, 8시간 정도만 주소가 유지됨 (실행 이후 주소 고정을 원할 경우 ‘인증토큰’을 추가해줘야 함  다음 장)
  • 7. Ngrok 인증 토큰 추가 • Ngrok 회원 가입 필요 • 토큰 추가는 무료 • 무료 계정은 분당 요청 : 분당 약 40회까지 허용 유료 계정은 분당 약 120회 회원 가입 후 ‘Your Authtoken’ 메뉴 이동하여 토큰 확인 # ngrok config add-authtoken “인증 토큰” Ngrok 서비스 중지 후 위 명령어 실행  Ngrok 서비스 실행
  • 8. Ngrok 인증 토큰 추가 인증 토큰 추가 후, 재시작한 Ngrok 서비스에서 변경된 접속 주소 확인 후, 해당 주소로 접속 ‘Visit Site’ 버튼 클릭
  • 9. 외부 도메인 연결 + https 적용 준비사항 : 도메인 준비 예> 가비아 이벤트용 도메인 1년에 2,000원 [참고]
  • 10. 도메인 등록 및 CNAME 설정 • 도메인 등록 및 CNAME 설정 후 nslookup으로 등록여부 확인 - 최초 도메인 등록時 DNS전파에 일정 시간 소요 (0분~00분)
  • 11. certbot 설치 • Let’s Encrypt 인증서 발급 권장 도구 # yum install epel-release # yum install certbot python2-certbot-nginx # yum install certbot
  • 12. certbot을 활용한 인증서 발급 • certbot certonly -d [도메인명] --manual --preferred-challenges dns # certbot certonly -d server.kopo.online --manual --preferred-challenges dns 거의 모든 스텝을 ‘Y’로 입력 진행하다가, 우측의 DNS TXT 필드 입력 문구가 나오면 DNS관리에서 입력 및 저장을 먼저 완료하고 엔터를 입력해야 정상 진행됨
  • 13. 인증서 위치 확인 • /etc/letsencrypt/live/[도메인명]
  • 14. nginx에 인증서 설정 및 ssl 서비스 등록 • vi /etc/nginx/conf.d/default.conf • nginx -s reload server{ listen 443 ssl; server_name server.kopo.online; root /usr/share/nginx/html; index index.html; ssl_certificate /etc/letsencrypt/live/server.kopo.online/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/server.kopo.online/privkey.pem; }
  • 15. 로컬에서 자체 테스트 로컬 개발서버에서 hosts파일을 임시로 편집하여 로컬 브라우저로 접속하였을때 정상여부를 확인 정상이면 hosts파일은 원상복구
  • 16. 인증서 자동 갱신 크론탭 등록 # crontab -e 0 0 1 * * root systemctl stop nginx && certbot renew -q && systemctl start nginx 매달 1일에 인증서 갱신 시도
  • 17. 외부 도메인과 Ngrok 연계 • server.kopo.online 도메인을 Ngrok으로 연계하기 위해서는 유료 계정을 사용해야 한다.
  • 18. 외부 도메인과 Ngrok 연계 • 유료 계정 가입 후 아래 링크로 이동 25$/month, 1년 단위 계약시 20$/month • https://dashboard.ngrok.com/cloud-edge/domains
  • 20. 외부 도메인과 Ngrok 연계 • Ngrok에서 도메인 추가하기 전에 기등록한 CNAME은 삭제해야 함 (미삭제시 Ngrok 에서 에러 발생) server.kopo.online 입력
  • 22. 외부 도메인과 Ngrok 연계 DNS 관리화면에 입력할 내용이므로 잠시 화면 정지
  • 23. 외부 도메인과 Ngrok 연계 ① 주어진 정보를 DNS 관리화면에 입력 및 저장 ② 저장 후 Ngrok 화면에서 다음 단계를 진행하면 전파된 DNS 정보를 조회하여 정상여부를 출력한다.
  • 24. 외부 도메인과 Ngrok 연계 • start tunnel 버튼을 클릭하면 아래와 같은 실행 명령을 제공 • 명령줄을 복사하여 서버에서 실행
  • 25. 외부 도메인과 Ngrok 연계 • 실행 결과 확인
  • 26. 외부 도메인과 Ngrok 연계 • 서버에서 /etc/hosts 편집
  • 27. 외부 도메인과 Ngrok 연계 • 서버에서 /etc/hosts 파일에 server.kopo.online을 추가해야 하는 이유 상기 내용 미반영시, 서버 외부 브라우저 접속시 인증서 불일치 경고 발생(서버내에 있는 브라우저는 정상 접속) 추정 사유> server.kopo.online 접속 -> ngrok 중계, ngrok 인증서 교환 -> 로컬 서버 응답 -> 응답시 server.kopo.online을 참조하는데 위와 같이 설정하지 않으면 다시 ngrok 서버 및 해당 인증서로 연계하여 접속 주소와 인증서의 불일치가 발생하게 됨 (상기 그림)
  • 28. [참고] Ngrok을 이용한 터미널 연결 • ngrok tcp 22

Editor's Notes

  1. https://crontab.guru/#0_0_1_*_*