mckaywrigley / chatbot-ui

Come join the best place on the internet to learn AI skills. Use code "chatbotui" for an extra 20% off.
https://JoinTakeoff.com
MIT License
28.65k stars 7.97k forks source link

Any way to set proxy? #60

Closed kilasuelika closed 9 months ago

kilasuelika commented 1 year ago

I have a networking problem and it seems that I have to set a proxy. Message:

 [TypeError: fetch failed] {
  cause:  [ConnectTimeoutError: Connect Timeout Error] {
  name: 'ConnectTimeoutError',
  code: 'UND_ERR_CONNECT_TIMEOUT',
  message: 'Connect Timeout Error'
}
mckaywrigley commented 1 year ago

Unsure how to fix this. I’ll leave this open to see if someone else has any tips.

wushuanger commented 1 year ago

have the same problem

frogchou commented 1 year ago

docker logs show this problem

gaoshilei commented 1 year ago

I've encountered the same issue. The project is deployed on Linux and the http proxy http://127.0.0.1:7890 has already been set up. However, errors still occur. Does the project have a function for proxy settings?

peizh commented 1 year ago

Same issue here.

LiuCao commented 1 year ago

I have the same needs

Jungley8 commented 1 year ago

Using the Docker environment variable OPENAI_API_HOST can help you.

ryanhex53 commented 1 year ago

Setup a proxy server by using the this code:

Then set environment variable OPENAI_API_HOST to http://<your-proxy-server-ip>

LiuCao commented 1 year ago

Using the Docker environment variable OPENAI_API_HOST can help you. 源码全局一搜索,里有还真有这个环境变量。 👍 👍 👍 👍

outp1 commented 1 year ago

I could try to add a connection through the proxy server function using pull request. It would be more convenient than the solutions above.

yuhr123 commented 1 year ago

Here is a simple method to configure a reverse proxy for https://api.openai.com using Caddy. First, install Caddy on your cloud server and bind a domain name to the server, such as example.com. Then add the following configuration to the Caddyfile:

example.com {
  reverse_proxy /* https://api.openai.com {
    header_up Host api.openai.com
    header_up X-Forwarded-Proto {scheme}
    header_up X-Forwarded-For {remote}
  }
}

Restart Caddy service, you can use https://example.com to send requests to the OpenAI API. As for Chatbot-UI, you can add OPENAI_API_HOST=https://example.com in the .env.local file to set up it.

windysnows commented 1 year ago

Setup a proxy server by using the this code:

Then set environment variable OPENAI_API_HOST to http://<your-proxy-server-ip>

how to use this proxy.js,which releative path can set it?

DengFist commented 1 year ago

Have you solved it yet?

frogchou commented 1 year ago

I deployed this project using Docker. I accessed the OpenAI API from a server in the United States while I was in mainland China. Before that, I tried to use an HTTP proxy on my Linux server in China, but it failed. So, I used Nginx to configure a reverse proxy on my server in the United States. Therefore, I did not directly use https://api.openai.com/, but instead used my own server's domain, http://mydomain.com/.

First, I built a local image using the command "docker build chatgpt-ui:4.12 .". Then, I created a container using the command "docker run -itd -e OPENAI_API_KEY=skXXXXXXXXX -e OPENAI_API_HOST=http://mydomain.com/ -p 3100:3000 --name openai-chat chatgpt-ui:4.12". However, it still did not work. When I entered a question in the chat interface, there was no response.

So, I used the command "docker exec -it openai-chat sh" to enter the container and searched for all content related to https://api.openai.com/ in the project. I replaced them all with http://mydomain.com/ and then restarted the container. It worked properly after that. I am not familiar with script languages, so I had to make these changes in a rough way. However, there are still many issues in the project, and I am looking forward to the author's improvements.