C.W.K.
Stream
Lesson 10 of 12 · published

LocalForward — 원격 서비스 도달

~15 min · port-forwarding, localforward, ssh-tunnel

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

원격 서비스를 localhost 로 가져오기

Local port forwarding 이 로컬 머신의 port 에서 원격 쪽 port 로 터널 생성. 원격 서비스가 로컬에 도는 것처럼 느껴짐. 패턴 — DB, 웹앱, 또는 admin UI 가 원격 서버에 도는데 네트워크에 노출 안 됨; local forwarding 이 private 접근 줌.

머릿속 모델

구문 — -L local-port:remote-host:remote-port. remote-hostSSH 서버 시점에서 해석 — 네 시점 아님. 그래서 -L 8080:localhost:80 는 "내 localhost:8080 을 서버가 부르는 localhost — 즉 서버 자체 — 로 forward". 서버 통해 제 3 host 도달은 localhost 를 그 host 주소로 바꿔.

Code

Local forwarding 패턴·bash
# Reach a web app on the server's localhost:80 via your localhost:8080
ssh -L 8080:localhost:80 server
# Now: open http://localhost:8080 in your browser

# Reach a third-party host through the bastion
# Local 5432 → bastion → database.internal:5432
ssh -L 5432:database.internal:5432 bastion

# Background tunnel, no shell — daemon-like
ssh -NfL 8080:localhost:80 server
# -N: no remote command  -f: background after auth
~/.ssh/config 에 박기·ssh-config
Host server-web
    HostName 192.168.1.11
    User you_username
    LocalForward 8080 localhost:80
    LocalForward 5432 localhost:5432

# Now `ssh server-web` opens both tunnels automatically
# while your shell runs

External links

Exercise

웹 서비스 도는 머신 (cwkPippa repo 면 Pippa 의 localhost:8000, 또는 원격 host 에 빠른 python3 -m http.server 8000) 에서 노트북 8080 으로 LocalForward 셋업. http://localhost:8080 브라우즈해서 원격 서비스 도달 확인. 그다음 ~/.ssh/config 에 박아서 ssh that-host 로 자동 열리게.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.