hello

Authentik + NPM(Nginx) + Cloudflare 로 백엔드에 대한 인증 적용

Share

Vultr를 이용하여 authentik, ghost를 설치하였습니다.

그리고 여기에 직접 구현한 backend app들을 추가하고 있습니다. 그런데 이 backend app들에 대해서는 지금 인증이 필요합니다. 누구에게나 보일 정보가 아니기 때문이죠

그래서 이를 구성하게 되었고, 그 과정을 정리해봅니다.

사전 준비사항

  • Authentik 서비스 (https://login.idecl.net)
    • Websocket 통신 적용 필요, 가급적이면 https 사용
  • Cloudflare에 도메인 등록. ex) *.idecl.net
  • NPM에 Letsencrypt 인증서 발급 - *.idecl.net

구성하기

  1. Proxy Provider를 구성합니다
- Name : my-provider                
# 인증을 적용할 서비스마다 provider가 생성될 예정이라 구분 가능하게 

- Authorization flow: default-provider-authorization-explicit-consent (Authorize Application)
# 이 플로우는 인증 과정에서 사용자가 애플리케이션이 자신의 정보를 액세스하는 것을 명확하게 승인해야 하는 경우에 사용됩니다. 보통 OAuth/OIDC 환경에서 권한 위임(Authorization Grant) 을 처리할 때 필요한 과정입니다.

- Forward Auth(Single Application)
# Forward Authentication(포워드 인증)은 Authentik을 역방향 프록시(Reverse Proxy) 앞에서 인증 게이트웨이처럼 사용하는 방식입니다. 특히, Single Application 모드는 하나의 특정 애플리케이션에 대해 인증을 강제하는 방식

- External Host
# 적용할 서비스의 도메인
  1. Application 등록

Create with Provider가 아닌 Create 선택

- Name 
# 자유롭게 입력한다. 보통 도메인을 입력하는게 직관적

- Slug
# 마찬가지로 도메인에서 가져옴

- Provider
# 앞서 만들었던 Provider 선택
  1. Outpost 갱신하기
  • Outpost는 이미 등록된 것을 수정하는 것인데, Applicatoin을 등록할때마다 선택을 해줘야 합니다
  • Advanced Settings에서 authentik_host의 경우 outpost를 맨처음 수정할때 한번만 해주면 됩니다. login을 할 authentik 도메인을 입력하기 때문이죠
  1. NPM 구성
  • Websocket을 설정합니다
  • 만들었던 인증서를 지정합니다. (그외 옵션들은 필요하면 선택)
# Increase buffer size for large headers
# This is needed only if you get 'upstream sent too big header while reading response
# header from upstream' error when trying to access an application protected by goauthentik
proxy_buffers 8 16k;
proxy_buffer_size 32k;

location / {
    # Put your proxy_pass to your application here
    proxy_pass          $forward_scheme://$server:$port;

    # authentik-specific config
    auth_request        /outpost.goauthentik.io/auth/nginx;
    error_page          401 = @goauthentik_proxy_signin;
    auth_request_set $auth_cookie $upstream_http_set_cookie;
    add_header Set-Cookie $auth_cookie;

    # translate headers from the outposts back to the actual upstream
    auth_request_set $authentik_username $upstream_http_x_authentik_username;
    auth_request_set $authentik_groups $upstream_http_x_authentik_groups;
    auth_request_set $authentik_email $upstream_http_x_authentik_email;
    auth_request_set $authentik_name $upstream_http_x_authentik_name;
    auth_request_set $authentik_uid $upstream_http_x_authentik_uid;

    proxy_set_header X-authentik-username $authentik_username;
    proxy_set_header X-authentik-groups $authentik_groups;
    proxy_set_header X-authentik-email $authentik_email;
    proxy_set_header X-authentik-name $authentik_name;
    proxy_set_header X-authentik-uid $authentik_uid;
}

# all requests to /outpost.goauthentik.io must be accessible without authentication
location /outpost.goauthentik.io {
    proxy_pass          https://수정이 필요/outpost.goauthentik.io;
    # ensure the host of this vserver matches your external URL you've configured
    # in authentik
    proxy_set_header     X-Forwarded-Host $host;
    proxy_set_header    X-Original-URL $scheme://$http_host$request_uri;
    add_header          Set-Cookie $auth_cookie;
    auth_request_set    $auth_cookie $upstream_http_set_cookie;

    # required for POST requests to work
    proxy_pass_request_body off;
    proxy_set_header Content-Length "";
}

# Special location for when the /auth endpoint returns a 401,
# redirect to the /start URL which initiates SSO
location @goauthentik_proxy_signin {
    internal;
    add_header Set-Cookie $auth_cookie;
    return 302 /outpost.goauthentik.io/start?rd=$request_uri;
    # For domain level, use the below error_page to redirect to your authentik server with the full redirect path
    # return 302 https://authentik.company/outpost.goauthentik.io/start?rd=$scheme://$http_host$request_uri;
}
  • 수정이 필요 라고 되어 있는 부분을 수정해야 합니다.
  • npm 입장에서 authentik에 접근하기 위한 URL이 해당됩니다.
  • 보통 npm과 authentik은 같은 node에 있기 때문에 컨테이너 통신을 위한 IP 대역이 있는데 그것을 입력하면 됩니다. 예를 들어 npm은 172.17.0.3 이고 authentik이 172.17.0.5로 할당되어 있다면 172.19.0.4:9443를 입력하게 됩니다.
  • 참고로 :9443은 https이기 때문에 그에 맞게 프로토콜도 https로 해야 합니다. 이게 불일치 하면 500 에러를 만나게 됩니다

이렇게 하면 이제 해당 서비스 접근 시 authentik에 인증이 되어 있지 않으면 강제로 로그인 페이지로 전송이 되고, 로그인을 하여야만 웹서비스 이용이 가능해집니다.

Read more

AI 에이전트 시대의 코드 호스팅: Cursor ‘Origin’은 왜 등장했나

AI 코딩 도구로 빠르게 성장한 Cursor가 이제 코드 에디터를 넘어 코드 호스팅 영역까지 확장하고 있습니다. 2026년 8월 17일 Cursor는 Origin이라는 새로운 코드 호스팅 서비스를 early beta로 공개했습니다. 쉽게 말하면 GitHub처럼 Git 저장소를 만들고, 코드를 올리고, Pull Request(PR)를 만들고 리뷰할 수 있는 서비스입니다. 그런데 단순히 "Cursor가 GitHub 비슷한

By JHL

코딩 에이전트에 1,000억 토큰을 써보니, 병목은 모델 밖에 있었다

Codex 화면에 집계된 누적 사용량은 약 866억 토큰이었다. Claude는 내가 확인할 수 있었던 로컬 머신의 집계값만 합쳐도 약 127억 토큰이었다. 다만 Claude는 여러 워크스테이션과 서버에서 사용했고, 중간에 사용량 데이터를 한 번 날려버리기도 했다. 누락된 머신과 기간을 감안하면 실제 사용량은 300억 토큰을 넘었을 가능성이 높다. 여기에 Ollama Cloud로 사용한 GLM, Qwen

By JHL

AI가 짜준 코드가 배포 속도를 높였다면, 이제는 '신뢰성 가드레일'을 세울 때입니다

최근 많은 팀이 AI 코딩 어시스턴트나 에이전트를 도입하면서 코드 생산 속도가 비약적으로 상승했습니다. 하지만 속도가 빨라졌다는 것은 그만큼 잠재적인 결함이 프로덕션 환경으로 유입되는 속도 또한 빨라졌음을 의미합니다. DevOps.com의 이번 글은 AI가 생성한 코드의 특성과 그로 인해 발생하는 새로운 유형의 리스크, 그리고 이를 제어하기 위한 '신뢰성 가드레일(Reliability Guardrails)

By JHL

LLM 시대, 프롬프트 엔지니어링보다 '도메인 전문성'이 더 강력한 무기인 이유

최근 AI 도구들이 비약적으로 발전하면서 '프롬프트 엔지니어링'이라는 기술적 기법에 많은 관심이 쏠렸습니다. 하지만 실제 현업에서 LLM을 극한으로 활용해 고도의 결과물을 만들어내는 사람들의 공통점은 정교한 프롬프트 템플릿을 쓰는 능력이 아니라, 해당 분야에 대한 깊은 '도메인 전문성'을 갖추고 있다는 점입니다. 많은 이들이 LLM이 지식의 격차를 줄여준다고

By JHL