환경 정보 준비
| 항목 | 값 |
|---|---|
| 내부 Jenkins 주소 | http://192.168.1.75:8080 |
| 공개 서버 IP | 111.27.135.123 |
| FRP 버전 | 0.62.0 (/root/frp_0.62.0_linux_amd64에 설치) |
| 포트 접속 주소 | http://111.27.135.123:18080 |
| 도메인 접속 주소 | http://jenkins.example.com:8081 |
FRP 다운로드 및 설치
공식 다운로드 위치:
https://github.com/fatedier/frp/releases
Linux x86_64 시스템에서 명령어로 설치:
# 설치 디렉토리 이동
cd /etc
# 최신 버전 다운로드
wget https://ghfast.top/https://github.com/fatedier/frp/releases/download/v0.58.0/frp_0.58.0_linux_amd64.tar.gz
# 압축 해제
tar -xzvf frp_0.62.1_linux_amd64.tar.gz
# 디렉토리 이름 변경 및 이동
mv frp_0.58.0_linux_amd64 frp
cd frp
설치 후 디렉토리 구조:
frp/
├── frpc # 클라이언트 실행 파일
├── frpc.toml # 클라이언트 설정 템플릿
├── frps # 서버 실행 파일
├── frps.toml # 서버 설정 템플릿
- Jenkins 서버(내부):
frpc실행 - 공개 서버:
frps실행
공개 서버 frps 설정
1. frps.toml 설정 파일 수정
[common]
bind_port = 7000 # 클라이언트 연결 포트
vhost_http_port = 8081 # 도메인 HTTP 접속 포트
dashboard_port = 7500 # 관리 페이지 포트 (선택사항)
7000번 포트 방화벽/보안그룹 개방 필요
2. systemd 서비스 파일 생성
/etc/systemd/system/frps.service:
[Unit]
Description=FRP Server Daemon
After=network.target
[Service]
Type=simple
User=root
ExecStart=/root/frp_0.62.0_linux_amd64/frps -c /root/frp_0.62.0_linux_amd64/frps.toml
Restart=on-failure
[Install]
WantedBy=multi-user.target
3. 서비스 시작 및 자동 실행 설정
systemctl daemon-reexec
systemctl daemon-reload
systemctl start frps
systemctl enable frps
4. 방화벽 포트 개방
- TCP 7000 (frpc 연결)
- TCP 18080 (포트 방식 Jenkins 접속)
- TCP 8081 (도메인 방식 Jenkins 접속)
내부 Jenkins 서버 frpc 설정
1. frpc.toml 설정 파일 생성
[common]
server_addr = 111.27.135.123
server_port = 7000
# TCP 포트 접속 방식
[jenkins-direct]
type = tcp
local_ip = 127.0.0.1
local_port = 3000
remote_port = 18080
# 도메인 접속 방식
[jenkins-web]
type = http
local_ip = 127.0.0.1
local_port = 3000
custom_domains = jenkins.xll.cn
2. systemd 서비스 파일 생성
/etc/systemd/system/frpc.service:
[Unit]
Description=FRP Client Daemon
After=network.target
[Service]
Type=simple
User=root
ExecStart=/root/frp_0.62.0_linux_amd64/frpc -c /root/frp_0.62.0_linux_amd64/frpc.toml
Restart=on-failure
[Install]
WantedBy=multi-user.target
3. 서비스 시작 및 자동 실행 설정
systemctl daemon-reexec
systemctl daemon-reload
systemctl start frpc
systemctl enable frpc
도메인 DNS 설정
jenkins.example.com 도메인의 A 레코드를 공개 서버 IP 120.27.135.183로 설정
접속 방법 요약
| 방식 | 주소 |
|---|---|
| 포트 접속 | http://111.27.135.123:18080 |
| 도메인 접속 | http://jenkins.example.com:8081 |
Nginx 리버스 프록시 설정 (권장)
server {
listen 80;
server_name jenkins.xll.cn;
location / {
proxy_pass http://127.0.0.1:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
| 항목 | 설명 |
|---|---|
server_name | frpc 설정과 동일한 도메인 |
proxy_pass | frps HTTP 포트(8081)로 전달 |
proxy_set_header | 실제 클라이언트 IP 정보 유지 |
접속 테스트
- 브라우저에서
http://jenkins.example.com접속 - Dashboard 상태 확인:
http://<공개IP>:7500