환경 : Ubuntu 24.04.3 / 램 16G
SaaS를 사용 못하는 내부망에서 사용하기 위함
2025.08.12 기준
1. 도커 설치 (https://docs.docker.com/engine/install/ubuntu/ 참조)
$ wget https://download.docker.com/linux/ubuntu/dists/noble/pool/stable/amd64/containerd.io_1.7.27-1_amd64.deb && \
wget https://download.docker.com/linux/ubuntu/dists/noble/pool/stable/amd64/docker-ce-cli_28.3.3-1~ubuntu.24.04~noble_amd64.deb && \
wget https://download.docker.com/linux/ubuntu/dists/noble/pool/stable/amd64/docker-ce_28.3.3-1~ubuntu.24.04~noble_amd64.deb && \
wget https://download.docker.com/linux/ubuntu/dists/noble/pool/stable/amd64/docker-buildx-plugin_0.26.1-1~ubuntu.24.04~noble_amd64.deb && \
wget https://download.docker.com/linux/ubuntu/dists/noble/pool/stable/amd64/docker-compose-plugin_2.39.1-1~ubuntu.24.04~noble_amd64.deb
$ sudo dpkg -i ./containerd.io_1.7.27-1_amd64.deb ./docker-ce-cli_28.3.3-1~ubuntu.24.04~noble_amd64.deb ./docker-ce_28.3.3-1~ubuntu.24.04~noble_amd64.deb ./docker-buildx-plugin_0.26.1-1~ubuntu.24.04~noble_amd64.deb ./docker-compose-plugin_2.39.1-1~ubuntu.24.04~noble_amd64.deb
$ sudo service docker start & sudo docker run hello-world
2. 리버스 프록시 설치
$ sudo apt-get install nginx
# 인증서 만들기
$ IP=192.168.130.189
$ sudo openssl req -x509 -newkey rsa:2048 -days 825 -nodes -subj "/CN=${IP}" -addext "subjectAltName = IP:${IP}" -keyout /etc/ssl/private/sentry-ip.key -out /etc/ssl/certs/sentry-ip.crt
$ sudo vim /etc/nginx/sites-available/sentry.conf
# 80 -> 443 리다이렉트
server {
listen 80;
return 301 https://$host$request_uri;
}
# HTTPS 종단 (IP 기반, 기본 서버)
server {
listen 443 ssl http2;
ssl_certificate /etc/ssl/certs/sentry-ip.crt;
ssl_certificate_key /etc/ssl/private/sentry-ip.key;
client_max_body_size 50m;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9000;
}
}
$ sudo ln -s /etc/nginx/sites-available/sentry.conf /etc/nginx/sites-enabled/sentry.conf
$ sudo nginx -t
$ sudo systemctl reload nginx
3. Self-Hosted Sentry 설치 (https://develop.sentry.dev/self-hosted/ 참조)
$ sudo apt-get install git curl
$ VERSION=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/getsentry/self-hosted/releases/latest)
$ VERSION=${VERSION##*/}
$ git clone https://github.com/getsentry/self-hosted.git
4 cd self-hosted
$ git checkout ${VERSION}
$ sudo ./install.sh
$ vim sentry/config.yml
system.url-prefix: "https://192.168.130.189"
$ vim sentry/sentry.conf.py
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
USE_X_FORWARDED_HOST = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
CSRF_TRUSTED_ORIGINS = ["https://192.168.130.189"]
$ sudo sed -i -E 's|proxy_set_header[[:space:]]+X-Forwarded-Proto[[:space:]]+\$scheme;|proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;|g' nginx.conf
$ sudo docker compose up --wait
4. curl + sentry 에러 전송 예제
라이브러리 설치
$ sudo apt install -y libcurl4-openssl-dev
$ git clone --recursive https://github.com/getsentry/sentry-native.git
$ cd sentry-native
$ cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo # 백엔드는 기본값 사용
$ cmake --build build --parallel
$ sudo cmake --install build
CMakeLists.txt 생성
cmake_minimum_required(VERSION 3.20)
project(app CXX)
find_package(sentry CONFIG REQUIRED)
add_executable(app main.cpp)
target_link_libraries(app PRIVATE sentry::sentry)
#include <sentry.h>
#include <cstdio>
#include <stdexcept>
int main() {
const char* DSN = "https://님_공개키@192.168.130.189/2";
sentry_options_t* options = sentry_options_new();
sentry_options_set_debug(options, 1);
sentry_options_set_logger(options,
[](sentry_level_e lvl, const char* msg, void*) {
std::fprintf(stderr, "[sentry:%d] %s\n", (int)lvl, msg);
}, nullptr);
sentry_options_set_dsn(options, DSN);
sentry_options_set_database_path(options, ".sentry-native");
sentry_options_set_ca_certs(options, "아까만든인증서.crt");
sentry_options_set_release(options, "myproject@1.0.0");
sentry_options_set_handler_path(options, "/usr/local/bin/crashpad_handler");
// 원한다면 환경/태그
sentry_options_set_environment(options, "dev");
if (sentry_init(options) != 0) {
throw std::runtime_error("sentry_init failed");
}
// 테스트 이벤트
std::array<void*, 256> frames{};
int n = backtrace(frames.data(), frames.size());
sentry_value_t st = sentry_value_new_stacktrace(frames.data(), n);
sentry_value_t exc = sentry_value_new_exception("error", std::string(msg).c_str());
sentry_value_set_by_key(exc, "stacktrace", st);
sentry_value_t evt = sentry_value_new_event();
sentry_event_add_exception(evt, exc);
sentry_capture_event(evt);
// 크래시
int* p = nullptr; *p = 42;
sentry_close();
}
4. sentry-cli 설치 및 환경 설정
https://192.168.130.189/settings/account/api/auth-tokens/new-token/ 에서 토큰 생성
$ curl -sL https://sentry.io/get-cli/ | bash
# 환경 파일 설정
$ vim ~/.sentryclirc
[defaults]
url = https://192.168.130.189
org = sentry # 조직 slug
project = agent # 프로젝트 slug
[http]
verify_ssl = false
[auth]
token = 님_토큰
# 정상 동작 확인
$ sentry-cli info
# 조직 slug 확인
$ sentry-cli organizations list
+----+--------+--------+--------------+---------------+--------------+
| ID | Name | Slug | Date Created | Early Adopter | Requires 2FA |
+----+--------+--------+--------------+---------------+--------------+
| 1 | Sentry | sentry | 2025-08-12 | false | false |
+----+--------+--------+--------------+---------------+--------------+
# 프로젝트 slug 확인
$ sentry-cli projects list -o sentry
+----+----------+--------+----------+
| ID | Slug | Team | Name |
+----+----------+--------+----------+
| 1 | internal | Sentry | Internal |
| 2 | agent | Sentry | agent |
+----+----------+--------+----------+
# 파일 유효성 확인
$ sentry-cli debug-files check 님_실행파일
# 분리 심볼 생성
objcopy --only-keep-debug 님_실행파일 님_실행파일.debug
objcopy --add-gnu-debuglink=님_실행파일.debug 님_실행파일
# 파일 업로드
$ sentry-cli debug-files upload --include-sources 님_실행파일 님_실행파일.debug
5. 크래시패드 정상 전송을 위해 프로그램을 설치한 pc에 인증서 설치
# sentry 서버에서 인증서 가져와서 루트 인증서에 설정
$ sudo cp sentry-ip.crt /usr/local/share/ca-certificates/sentry-ip.crt
$ sudo update-ca-certificates