Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: can't use API from workflows when IP Restriction is enabled #42

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

WinterYukky
Copy link
Contributor

Issue #, if available:
#41

Description of changes:
Add internal endpoint and allow connection ALB from ECS service.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@tmokmss
Copy link
Contributor

tmokmss commented Mar 6, 2025

@WinterYukky リファクタと修正を分けたりできますか…?
本質的な修正は AlbWithCloudFront.urlをCloudFrontではなくALBのURLにすることですかね?

これで動くのかが自信なく
例えば公式には CONSOLE_WEB_URL はCORSに使われたりするので、ユーザーが触るURLでなければならないはずです
https://docs.dify.ai/getting-started/install-self-hosted/environments

@WinterYukky
Copy link
Contributor Author

WinterYukky commented Mar 6, 2025

リファクタと修正を分けたりできますか…?

👌

本質的な修正は AlbWithCloudFront.urlをCloudFrontではなくALBのURLにすることですかね?

その可能性もありますが、今のところ修正案は 3 つあり今回は 3 番を採用しています。

  1. AlbWithCloudFront.url を CloudFront`ではなく ALB の URL にする
    1. この構成は確認しておらず影響は不明
  2. CloudFront の WAF の IP リストに NAT Gateway の IP アドレスを追加する
    1. リクエストが VPC 外経由になるが、シンプルなエンドポイント運用になる
  3. ECS サービスから ALB への SG を許可する
    1. VPC 内で完結できるがエンドポイントが 2 つになる

API 利用を ALB 経由にするならその修正もありだと思います。ただ、それでは私も動作がどうなるか分かっておらず。
私の修正では Worker からのリクエストを VPC 内だけで完結させる修正になります。CloudFront 経由の場合は URL が一つになって分かりやすいですがリクエストをインターネット経由にする必要があります。Worker からのリクエストなのでユーザーのアクセス経路は変わらず CORS も考慮不要なので VPC 内の通信にしようと思い IntenalUrl を追加しました。下図の赤色ルートが 3 番になります。

image

@tmokmss
Copy link
Contributor

tmokmss commented Mar 6, 2025

ありがとうございます、リファクタが含まれず変更が最小限の状態になったら、もう一度確認したいと思いますmm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants