Network

VPN 없이 private 망 도메인 접근하기 (PortForwarding)

gepp 2024. 6. 18. 17:11

 

 

  • 환경
    • Mac with Public Secured Wifi -> Public EC2 -> Private Load Balancers and Private EC2 Proxy -> docker on Private EC2

 

# Modify /private/etc/hosts file

127.0.0.1 <Target Domain>

 

 

# Modify .zshrc file

alias <alias name>='ssh -i <your key file name>.pem <username>@<public EC2 IP> -p <public EC2 port> \
	-g -L <local port which is not in use>:<target domain name>:<target port> \
    -g -L <local port which is not in use>:<target domain name>:<target port>'

 

source .zshrc
<type alias name>

 

터미널에서 Public EC2 에 들어가지면 브라우저에서 <접속할 타겟 도메인>:<지정한 로컬포트> 로 입력합니다.

Public EC2 를 거쳐 내부 Private 도메인에 접속이 됩니다.

이때 접속할 소스가 Public EC2 보안그룹에 허용되어 있어야 합니다.