-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
64 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Load Balancing and Routing | ||
|
||
Langflow (at least at version 1.0.15) expects all URLs to be rooted from `/`: there is not a straightforward way to configure a `base_url` or similar. | ||
This is a challenge for load balancers and other application routers. This goal of this page is to inform you about some tricks you can use | ||
to configure your own system; it is based on the popular Nginx framework but should be easily translatable to whatever framework you use. | ||
|
||
## Server Proxy | ||
|
||
Consider this Nginx `server` configuration, which allows Langflow developers to access the UI at `langflow.dev.internal` on port `80`, | ||
whilst routing requests to `langflow.dev.service` on port `7860`: | ||
|
||
``` | ||
server { | ||
listen 80; | ||
server_name langflow.dev.internal; | ||
location / { | ||
proxy_pass http://langflow.dev.service:7860; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
} | ||
``` | ||
|
||
## Server Proxy with Routing | ||
|
||
To add an application routing based on URL (in this case `/chat`), use the route to identify the destination location, but | ||
remove the route from the URL before passing to Langflow: | ||
|
||
``` | ||
server { | ||
listen 80; | ||
server_name langflow.test.internal; | ||
location /chat { | ||
rewrite ^/chat/(.*)$ /$1 break; | ||
proxy_pass http://langflow.test.service:7860; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
} | ||
} | ||
``` | ||
|
||
Two important things to note about this routing approach: | ||
|
||
1. The Langflow frontend will not work without a '/' location, but backend API calls should. You can combine both locations within the `server` configuration. | ||
2. Some returned content (such as when an API is called with `stream=true`) includes URLs that will not be prefixed (i.e. `stream_url` will begin `/api/v1/...`); you will need to add the prefix within your application logic. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters