강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

두번째월급님의 프로필 이미지
두번째월급

작성한 질문수

수익형 AI Agent n8n 전문가 강의, 블로그·쇼츠 자동화

FastAPI와 n8n으로 만드는 실전 AI 검색 시스템

10강 29분 45초 부분에서 오류납니다...

해결된 질문

작성

·

34

0

1.png.webp

여기서 이런 오류가 떠서 url을 들어가보니까

2.png.webp

이런식으로 뜹니다...

gpt에게 물어보니
-----
지금 무슨 상태냐

  1. http://api.ownstory.kr/301로 https로 잘 리다이렉트
    도메인/DNS/가상호스트 매칭은 정상

  2. https://api.ownstory.kr/HEAD(= -I)도 500
    “POST 바디 처리 문제”가 아니라, 요청을 받는 순간 공통으로 500을 내고 있음
    → OpenResty/Nginx 레벨 공통 로직(특히 Lua/인증/프록시) 문제 가능성 ↑

  3. https://82.208.22.139/ -H "Host: api.ownstory.kr"TLS handshake 실패
    이건 이상해 보이지만, 윈도우 curl(schannel) + IP로 SNI 없이 접속할 때 흔히 깨져.
    즉 이 실패는 “서버가 고장”의 결정적 증거가 아니라, SNI/인증서 설정 때문에 IP 직결이 막힌 케이스로 보는 게 맞아.
    (도메인으로 접속하면 TLS는 정상인데, IP로 바로 때리면 인증서 선택이 안 맞아서 실패하는 경우가 흔함)


결론 한 줄

API 자체(백엔드) 라우트 문제가 아니라, OpenResty가 전역적으로 500을 내는 상태야.
→ 서버 로그 없이는 100% 확정은 못 해도, 원인 범위는 거의 이 두 개로 수렴해:

가장 유력

  • OpenResty 설정/스크립트(Lua)에서 런타임 에러
    (예: access_by_lua에서 인증 토큰 체크하다 nil 참조, 파일 경로 오류, env 누락 등)

  • 리버스프록시 업스트림 설정이 잘못되어 OpenResty가 내부적으로 500 처리
    (보통은 502가 많지만, Lua/커스텀 에러 핸들링이 있으면 500으로 뿜기도 함)

    이렇게 이야기를 해주는데...
    지금 무슨 상태냐

    1. http://api.ownstory.kr/301로 https로 잘 리다이렉트
      도메인/DNS/가상호스트 매칭은 정상

    2. https://api.ownstory.kr/HEAD(= -I)도 500
      “POST 바디 처리 문제”가 아니라, 요청을 받는 순간 공통으로 500을 내고 있음
      → OpenResty/Nginx 레벨 공통 로직(특히 Lua/인증/프록시) 문제 가능성 ↑

    3. https://82.208.22.139/ -H "Host: api.ownstory.kr"TLS handshake 실패
      이건 이상해 보이지만, 윈도우 curl(schannel) + IP로 SNI 없이 접속할 때 흔히 깨져.
      즉 이 실패는 “서버가 고장”의 결정적 증거가 아니라, SNI/인증서 설정 때문에 IP 직결이 막힌 케이스로 보는 게 맞아.
      (도메인으로 접속하면 TLS는 정상인데, IP로 바로 때리면 인증서 선택이 안 맞아서 실패하는 경우가 흔함)


    결론 한 줄

    API 자체(백엔드) 라우트 문제가 아니라, OpenResty가 전역적으로 500을 내는 상태야.
    → 서버 로그 없이는 100% 확정은 못 해도, 원인 범위는 거의 이 두 개로 수렴해:

    가장 유력

    • OpenResty 설정/스크립트(Lua)에서 런타임 에러
      (예: access_by_lua에서 인증 토큰 체크하다 nil 참조, 파일 경로 오류, env 누락 등)

    • 리버스프록시 업스트림 설정이 잘못되어 OpenResty가 내부적으로 500 처리
      (보통은 502가 많지만, Lua/커스텀 에러 핸들링이 있으면 500으로 뿜기도 함)

    •  


      이렇게 얘기하는데 어떻게 해결해야되는건지 모르겠습니다 ㅠㅠ

답변 2

1

남박사님의 프로필 이미지
남박사
지식공유자

안녕하세요, 두번째월급님.

문의주신 내용은 여러가지 항목들을 체크해보면서 원인을 찾아봐야 하는 문제로 보입니다. 사실 그리 어려운 내용은 아닐수 있으나 여러가지가 복합적으로 얽혀있는 문제일 수 있기에 이런 환경에 익숙하지 않은 입장에서는 다소 어렵고 복잡하게 느껴지실 수도 있긴 합니다.

 

image.png

일단 이 에러문구는 메서드 (POST, GET, PUT, PATH, DELETE) 가 올바르지 않아서 생기는 문제입니다. 강의에서는 POST 메서드를 통해서 진행을 하고 있는 부분입니다만 일단 먼저 체크해봐야 할 부분은,

  1. api 서버로 동작하는 파이썬 도커 컨테이너가 정상 동작중인지 확인.

  2. 파이썬 도커가 정상 동작중이라면 api 서브 도메인이 제대로 서버 아이피를 향하고 있는지 확인.

  3. 서버 아이피 설정이 문제가 없다면 NPM에서 api 서브 도메인이 proxy 설정이 제대로 되어있는지 확인

  4. NPM에 proxy 설정이 제대로 되어있다면 SSL 인증서가 제대로 설정 되어있는지 확인

위 4가지 사항에 모두 문제가 없다면 서버 설정에는 문제가 없다고 판단할 수 있고 그렇다면 파이썬 코드에서 어떤 문제가 발생하는지 로그를 보면서 체크해봐야 할 부분으로 보입니다.

강의 25분 30초 쯤을 보시면 파이썬 도커 컨테이너에서 로그를 어떻게 확인하는지에 대한 내용이 잠깐 나옵니다. n8n에서 다시 동작을 수행해보고 오류가 발생하면 이때 파이썬 도커 컨테이너의 로그 내용을 한번 올려봐주시기 바랍니다. 현재 AI 의 답변은 너무 장황하고 복잡한 내용, 그리고 불필요한 내용이 너무 많습니다. AI 답변은 항상 참고용으로만 생각하시고 직접 문제의 원인을 찾아보고 이해하는데 초점을 두는게 좋다고 생각합니다. (물론 이 모든걸 다 이해하기가 첨부터 쉽지는 않습니다.)

다시 위의 항목들을 체크해보시고 오류가 지속되면 로그 내용을 다시 올려주시면 제가 한번 확인해보도록 하겠습니다.

Permissions 0644 for n8n settings file /home/node/.n8n/config are too wide. This is ignored for now, but in the future n8n will attempt to change the permissions automatically. To automatically enforce correct permissions now set N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true (recommended), or turn this check off set N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false.

Initializing n8n process

n8n ready on ::, port 5678

There are deprecations related to your environment variables. Please take the recommended actions to update your configuration:

- N8N_RUNNERS_ENABLED -> Running n8n without task runners is deprecated. Task runners will be turned on by default in a future version. Please set N8N_RUNNERS_ENABLED=true to enable task runners now and avoid potential issues in the future. Learn more: https://docs.n8n.io/hosting/configuration/task-runners/

- N8N_BLOCK_ENV_ACCESS_IN_NODE -> The default value of N8N_BLOCK_ENV_ACCESS_IN_NODE will be changed from false to true in a future version. If you need to access environment variables from the Code Node or from expressions, please set N8N_BLOCK_ENV_ACCESS_IN_NODE=false. Learn more: https://docs.n8n.io/hosting/configuration/environment-variables/security/

- N8N_GIT_NODE_DISABLE_BARE_REPOS -> Support for bare repositories in the Git Node will be removed in a future version due to security concerns. If you are not using bare repositories in the Git Node, please set N8N_GIT_NODE_DISABLE_BARE_REPOS=true. Learn more: https://docs.n8n.io/hosting/configuration/environment-variables/security/

[license SDK] Skipping renewal on init: license cert is not initialized

Collaboration features are disabled because push is configured unidirectional. Use N8N_PUSH_BACKEND=websocket environment variable to enable them.

Version: 1.123.5

Editor is now accessible via:

https://n8n.ownstory.kr

Origin header does NOT match the expected origin. (Origin: "undefined" -> "N/A", Expected: "undefined" -> "undefined", Protocol: "undefined")

ResponseError: Invalid origin!

at Push.handleRequest (/usr/local/lib/node_modules/n8n/src/push/index.ts:143:10)

at /usr/local/lib/node_modules/n8n/src/push/index.ts:99:10

at Layer.handleRequest (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/lib/layer.js:152:17)

at trimPrefix (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:342:13)

at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:297:9

at processParams (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:582:12)

at next (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:291:5)

at /usr/local/lib/node_modules/n8n/src/auth/auth.service.ts:144:18

at processTicksAndRejections (node:internal/process/task_queues:105:5)

ValidationError: The 'X-Forwarded-For' header is set but the Express 'trust proxy' setting is false (default). This could indicate a misconfiguration which would prevent express-rate-limit from accurately identifying users. See https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/ for more information.

at Object.xForwardedForHeader (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/express-rate-limit@7.5.0_express@5.1.0/node_modules/express-rate-limit/dist/index.cjs:187:13)

at Object.wrappedValidations.<computed> [as xForwardedForHeader] (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/express-rate-limit@7.5.0_express@5.1.0/node_modules/express-rate-limit/dist/index.cjs:398:22)

at Object.keyGenerator (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/express-rate-limit@7.5.0_express@5.1.0/node_modules/express-rate-limit/dist/index.cjs:671:20)

at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/express-rate-limit@7.5.0_express@5.1.0/node_modules/express-rate-limit/dist/index.cjs:724:32

at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/express-rate-limit@7.5.0_express@5.1.0/node_modules/express-rate-limit/dist/index.cjs:704:5 {

code: 'ERR_ERL_UNEXPECTED_X_FORWARDED_FOR',

help: 'https://express-rate-limit.github.io/ERR_ERL_UNEXPECTED_X_FORWARDED_FOR/'

}

Origin header does NOT match the expected origin. (Origin: "undefined" -> "N/A", Expected: "undefined" -> "undefined", Protocol: "undefined")

ResponseError: Invalid origin!

at Push.handleRequest (/usr/local/lib/node_modules/n8n/src/push/index.ts:143:10)

at /usr/local/lib/node_modules/n8n/src/push/index.ts:99:10

at Layer.handleRequest (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/lib/layer.js:152:17)

at trimPrefix (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:342:13)

at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:297:9

at processParams (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:582:12)

at next (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:291:5)

at /usr/local/lib/node_modules/n8n/src/auth/auth.service.ts:144:18

at processTicksAndRejections (node:internal/process/task_queues:105:5)

Origin header does NOT match the expected origin. (Origin: "undefined" -> "N/A", Expected: "undefined" -> "undefined", Protocol: "undefined")

ResponseError: Invalid origin!

at Push.handleRequest (/usr/local/lib/node_modules/n8n/src/push/index.ts:143:10)

at /usr/local/lib/node_modules/n8n/src/push/index.ts:99:10

at Layer.handleRequest (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/lib/layer.js:152:17)

at trimPrefix (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:342:13)

at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:297:9

at processParams (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:582:12)

at next (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:291:5)

at /usr/local/lib/node_modules/n8n/src/auth/auth.service.ts:144:18

at processTicksAndRejections (node:internal/process/task_queues:105:5)

Origin header does NOT match the expected origin. (Origin: "undefined" -> "N/A", Expected: "undefined" -> "undefined", Protocol: "undefined")

ResponseError: Invalid origin!

at Push.handleRequest (/usr/local/lib/node_modules/n8n/src/push/index.ts:143:10)

at /usr/local/lib/node_modules/n8n/src/push/index.ts:99:10

at Layer.handleRequest (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/lib/layer.js:152:17)

at trimPrefix (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:342:13)

at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:297:9

at processParams (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:582:12)

at next (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:291:5)

at /usr/local/lib/node_modules/n8n/src/auth/auth.service.ts:144:18

at processTicksAndRejections (node:internal/process/task_queues:105:5)

Origin header does NOT match the expected origin. (Origin: "undefined" -> "N/A", Expected: "undefined" -> "undefined", Protocol: "undefined")

ResponseError: Invalid origin!

at Push.handleRequest (/usr/local/lib/node_modules/n8n/src/push/index.ts:143:10)

at /usr/local/lib/node_modules/n8n/src/push/index.ts:99:10

at Layer.handleRequest (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/lib/layer.js:152:17)

at trimPrefix (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:342:13)

at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:297:9

at processParams (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:582:12)

at next (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:291:5)

at /usr/local/lib/node_modules/n8n/src/auth/auth.service.ts:144:18

at processTicksAndRejections (node:internal/process/task_queues:105:5)

Origin header does NOT match the expected origin. (Origin: "undefined" -> "N/A", Expected: "undefined" -> "undefined", Protocol: "undefined")

ResponseError: Invalid origin!

at Push.handleRequest (/usr/local/lib/node_modules/n8n/src/push/index.ts:143:10)

at /usr/local/lib/node_modules/n8n/src/push/index.ts:99:10

at Layer.handleRequest (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/lib/layer.js:152:17)

at trimPrefix (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:342:13)

at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:297:9

at processParams (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:582:12)

at next (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/router@2.2.0/node_modules/router/index.js:291:5)

at /usr/local/lib/node_modules/n8n/src/auth/auth.service.ts:144:18

at processTicksAndRejections (node:internal/process/task_queues:105:5)

Blocked GET /robots.txt for "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36; compatible; OAI-SearchBot/1.3; robots.txt; +https://openai.com/searchbot"

Blocked GET / for "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.3; +https://openai.com/gptbot)"

Blocked GET /robots.txt for "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)"

Blocked GET / for "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)"

Blocked GET /robots.txt for "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

Blocked GET / for "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.122 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)"

Pruning old insights data

Pruning old insights data

[license SDK] license successfully activated

Blocked GET / for "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; GPTBot/1.3; +https://openai.com/gptbot)"

--
포르테이너의 n8n 컨테이너 로그는 이렇게 나옵니다!

남박사님의 프로필 이미지
남박사
지식공유자

로그만 봤을때 파이썬 코드에 /search URI 가 아예 등록이 안된걸로 보입니다. 파이썬 코드 전체를 한번 올려줘보셔야 할 듯 합니다. 질답 게시판에 올려주셔도 좋고 혹시 디스코드를 사용하신다면 nambaksa_ 로 보내주셔도 좋을듯 합니다.

0

안녕하세요, 인프런 AI 인턴입니다. 두번째월급님.

현재 설명하신 문제는 HTTP 메소드와 서버 상태와 관련된 문제로 보입니다. HTTP 요청에서 “Method not allowed” 오류가 발생하는 것은 일반적으로 잘못된 HTTP 메소드를 사용하고 있을 때 나타나며, “Internal Server Error”는 서버 측에서 요청을 처리하는 과정에서 예기치 않은 오류가 발생했음을 나타냅니다.

문제 파악 및 해결 방안

  1. HTTP 메소드 확인:

    • API 문서나 서버 설정에서 지원하는 정확한 HTTP 메소드를 확인하세요. 예를 들어, POST 요청이 필요한데 GET 요청을 하고 있는지 검토하세요.
  2. 서버 설정 문제:

    • OpenResty/Nginx 및 Lua 스크립트가 관련된 설정이나 스크립트 상의 문제를 점검해야 합니다. 서버 로그를 통해 정확한 런타임 에러 메시지를 확인하면 설정 오류나 스크립트 오류를 수정할 수 있을 것입니다.
  3. 요청에 포함된 헤더와 데이터 폼 점검:

    • 요청 시에 필요한 헤더 또는 데이터 형식이 제대로 설정되어 있는지 확인하세요. 인증 토큰이 필요한 경우 누락되진 않았는지, 올바른 형식으로 전달되고 있는지를 체크해야 합니다.
  4. 리버스 프록시 설정 검토:

    • Nginx나 OpenResty 프록시가 백엔드 서버로 요청을 제대로 전달하고 있는지 확인하세요. 테스트로 Apache나 다른 웹 서버/프록시로 라우팅하여 문제의 원인을 좁혀가는 것도 한 방법입니다.

아래의 링크는 유사한 문제를 다루었던 질문들로, 해결 방법을 이해하는 데 도움이 될 수 있습니다:

서버 로그를 기반으로 하여 문제를 보다 정확하게 진단할 수 있는 서버 관리자나 개발자와 협력하시길 권장드립니다. 그리고 위의 방법으로도 문제가 해결되지 않는 경우, 추가적인 서버 환경 정보와 로그 세부사항을 공유해 주시면 도움을 드릴 수 있는 방법을 더 찾아볼 수 있습니다.

저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다. 현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏 추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.

두번째월급님의 프로필 이미지
두번째월급

작성한 질문수

질문하기