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

incompatible with Docker-compose when enable host and proxy params. #25

Closed
wtlyu opened this issue Mar 11, 2023 · 2 comments
Closed

incompatible with Docker-compose when enable host and proxy params. #25

wtlyu opened this issue Mar 11, 2023 · 2 comments

Comments

@wtlyu
Copy link
Contributor

wtlyu commented Mar 11, 2023

From Issue #15

Here is the copy from @Kristovich and his test:

Kristovich

I'm using the docker compose from da62e9a. I built the api and client containers as instructed on the readme.

I also added console.log(`Line 11, host${host}port${port}`); line inside api/server/index.js. When - HOST="0.0.0.0" is set I get:

api_1      |
api_1      | > [email protected] start
api_1      | > node server/index.js
api_1      |
api_1      | Line 11, host"0.0.0.0"port3080
api_1      | node:events:490
api_1      |       throw er; // Unhandled 'error' event
api_1      |       ^
api_1      |
api_1      | Error: getaddrinfo ENOTFOUND "0.0.0.0"
api_1      |     at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26)
api_1      | Emitted 'error' event on Server instance at:
api_1      |     at GetAddrInfoReqWrap.doListen [as callback] (node:net:1934:12)
api_1      |     at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:17) {
api_1      |   errno: -3008,
api_1      |   code: 'ENOTFOUND',
api_1      |   syscall: 'getaddrinfo',
api_1      |   hostname: '"0.0.0.0"'
api_1      | }

If - HOST=0.0.0.0 then

api_1      | 
api_1      | > [email protected] start
api_1      | > node server/index.js
api_1      | 
api_1      | Line 11, host0.0.0.0port3080
api_1      | Server listening at http://0.0.0.0:3080

And while I'm at it: If - PROXY="" is present inside the docker-compose.yml, then the server will work but requests to openai or bing will fail with

api_1      | ask log {
api_1      |   model: 'chatgpt',
api_1      |   id: '[uuid]',
api_1      |   sender: 'User',
api_1      |   text: 'this is a test',
api_1      |   parentMessageId: undefined,
api_1      |   conversationId: undefined,
api_1      |   chatGptLabel: '',
api_1      |   promptPrefix: ''
api_1      | }
api_1      | TypeError [ERR_INVALID_URL]: Invalid URL
api_1      |     at new NodeError (node:internal/errors:399:5)
api_1      |     at new URL (node:internal/url:588:13)
api_1      |     at new ProxyAgent (/api/node_modules/undici/lib/proxy-agent.js:67:25)
api_1      |     at ChatGPTClient.getCompletion (file:///api/node_modules/@waylaidwanderer/chatgpt-api/src/ChatGPTClient.js:168:31)
api_1      |     at ChatGPTClient.sendMessage (file:///api/node_modules/@waylaidwanderer/chatgpt-api/src/ChatGPTClient.js:297:24)
api_1      |     at async askClient (/api/app/chatgpt-client.js:28:15)
api_1      |     at async /api/server/routes/ask.js:90:23 {
api_1      |   input: '""',
api_1      |   code: 'ERR_INVALID_URL'
api_1      | }

So I had to remove the PROXY env out of the docker-compose file for it to work.

I hope this helps.

@wtlyu
Copy link
Contributor Author

wtlyu commented Mar 11, 2023

Hi @danny-avila and @Kristovich

I have made some fully check of the previous pull request #19 . As motioned yesterday, it seems an incompatible issue with docker compose.

Here is my conclusion:

  1. In the case of local deployment, HOST and PROXY work as expected, specific tests will be listed later
    1. Before this PR, all interface will be listen, (- although this is very insecure, any user in the LAN can access it.). I changed to listen localhost by default, and user can set HOST=0.0.0.0 to expose to external network as before.
    2. 0.0.0.0 is not a real ip, so printing 0.0.0.0:3080 might be misleading. (actually, localhost:3080 or external_ip:3080 will be enabled in this case) I will start a new PR to improve this.
  2. In the case of docker-compose environment, as @Kristovich said, there is error message when - HOST="0.0.0.0" or - PROXY=""
    1. It turns out a wrong usage of docker-compose, in This and This .
    2. quotes shouldn't be used as - ENV="value", we can use - "ENV=value" or - 'ENV=value' or - ENV=value.
    3. both HOST and PROXY in @Kristovich 's test are the same issue of the quotes

I have mode those tests:

Local environment 
test1: HOST= and no PROXY:   works on localhost
test2: HOST=localhost and no PROXY:   works localhost
test1: HOST=0.0.0.0 and no PROXY:   works all interface
test1: HOST=192.168.xx.x and no PROXY:   works on external ip
test1: HOST= and no PROXY=http://127.0.0.1:8888:   works, using proxy.


Docker environemt:
test1:
    docker compose as original: 
    works but 502. (nothing wrong. localhost in docker means not accessable outside)

test2:
    Add - HOST=0.0.0.0
    works 

test3:
    Add - HOST="0.0.0.0"
    error as @Kristovich said.  

test4:
    Add - HOST=""
    error as @Kristovich said.  

test5:
    Add - "HOST=0.0.0.0"
    works 

test6:
    Add - 'HOST=0.0.0.0'
    works 

test7:
    Add - HOST=
    works but 502, as test 1. 

test7:
    Add - PROXY=""
    error as @Kristovich said.  

test7:
    Add - PROXY=
    works

@wtlyu
Copy link
Contributor Author

wtlyu commented Mar 11, 2023

In short.

That PR has no incompatible issue with docker. It's a wrong usage of docker-compose.yaml.

But I will open a new PR add this:

  1. add more information on HOST=0.0.0.0, removing the misleading information
  2. set env HOST=0.0.0.0 in api's Dockerfile by default. So that it won't break the README's docker demo.
  3. fix the wrong example in docker-compose.yaml. This might mislead @Kristovich to write - HOST="0.0.0.0":
        environment:
                - PORT=3080
                - MONGO_URI=mongodb://mongodb:27017/chatgpt-clone
                - OPENAI_KEY=""        <----- WRONG, use - OPENAI_KEY=
                - CHATGPT_TOKEN=""        <----- WRONG
                - BING_TOKEN=""        <----- WRONG

@wtlyu wtlyu closed this as completed Mar 11, 2023
danorlando added a commit that referenced this issue May 7, 2023
* server-side JWT auth implementation

* move oauth routes and strategies, fix bugs

* backend modifications for wiring up the frontend login and reg forms

* Add frontend data services for login and registration

* Add login and registration forms

* Implment auth context, functional client side auth

* protect routes with jwt auth

* finish local strategy (using local storage)

* Start setting up google auth

* disable token refresh, remove old auth middleware

* refactor client, add ApiErrorBoundary context

* disable google and facebook strategies

* fix: fix presets not displaying specific to user

* fix: fix issue with browser refresh

* fix: casing issue with User.js (#11)

* delete user.js to be renamed

* fix: fix casing issue with User.js

* comment out api error watcher temporarily

* fix: issue with api error watcher (#12)

* delete user.js to be renamed

* fix: fix casing issue with User.js

* comment out api error watcher temporarily

* feat: add google auth social login

* fix: make google login url dynamic based on dev/prod

* fix: bug where UI is briefly displayed before redirecting to login

* fix: fix cookie expires value for local auth

* Update README.md

* Update LOCAL_INSTALL structure

* Add local testing instructions

* Only load google strategy if client id and secret are provided

* Update .env.example files with new params

* fix issue with not redirecting to register form

* only show google login button if value is set in .env

* cleanup log messages

* Add label to button for google login on login form

* doc: fix client/server url values in .env.example

* feat: add error message details to registration failure

* Restore preventing paste on confirm password

* auto-login user after registering

* feat: forgot password (#24)

* make login/reg pages look like openai's

* add password reset data services

* new form designs similar to openai, add password reset pages

* add api's for password reset

* email utils for password reset

* remove bcrypt salt rounds from process.env

* refactor: restructure api auth code, consolidate routes (#25)

* add api's for password reset

* remove bcrypt salt rounds from process.env

* refactor: consolidate auth routes, use controller pattern

* refactor: code cleanup

* feat: migrate data to first user (#26)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes after refactor (#27)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: issue with auto-login when logging out then logging in with new browser window (#28)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: Update README and .env.example files with user system information (#29)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: update README and .env.example files

* Fixup: LOCAL_INSTALL.md PS instructions (#200) (#30)

Co-authored-by: alfredo-f <[email protected]>

* feat: send user with completion to protect against abuse (#31)

* Fixup: LOCAL_INSTALL.md PS instructions (#200)

* server-side JWT auth implementation

* move oauth routes and strategies, fix bugs

* backend modifications for wiring up the frontend login and reg forms

* Add frontend data services for login and registration

* Add login and registration forms

* Implment auth context, functional client side auth

* protect routes with jwt auth

* finish local strategy (using local storage)

* Start setting up google auth

* disable token refresh, remove old auth middleware

* refactor client, add ApiErrorBoundary context

* disable google and facebook strategies

* fix: fix presets not displaying specific to user

* fix: fix issue with browser refresh

* fix: casing issue with User.js (#11)

* delete user.js to be renamed

* fix: fix casing issue with User.js

* comment out api error watcher temporarily

* feat: add google auth social login

* fix: make google login url dynamic based on dev/prod

* fix: bug where UI is briefly displayed before redirecting to login

* fix: fix cookie expires value for local auth

* Only load google strategy if client id and secret are provided

* Update .env.example files with new params

* fix issue with not redirecting to register form

* only show google login button if value is set in .env

* cleanup log messages

* Add label to button for google login on login form

* doc: fix client/server url values in .env.example

* feat: add error message details to registration failure

* Restore preventing paste on confirm password

* auto-login user after registering

* feat: forgot password (#24)

* make login/reg pages look like openai's

* add password reset data services

* new form designs similar to openai, add password reset pages

* add api's for password reset

* email utils for password reset

* remove bcrypt salt rounds from process.env

* refactor: restructure api auth code, consolidate routes (#25)

* add api's for password reset

* remove bcrypt salt rounds from process.env

* refactor: consolidate auth routes, use controller pattern

* refactor: code cleanup

* feat: migrate data to first user (#26)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes after refactor (#27)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: issue with auto-login when logging out then logging in with new browser window (#28)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: Update README and .env.example files with user system information (#29)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: update README and .env.example files

* Send user id to openai to protect against abuse

* add meilisearch to gitignore

* Remove webpack

---------

Co-authored-by: alfredo-f <[email protected]>

---------

Co-authored-by: Danny Avila <[email protected]>
Co-authored-by: Alfredo Fomitchenko <[email protected]>
BlitzWrecker pushed a commit to BlitzWrecker/AITok that referenced this issue Jul 2, 2023
…nny-avila#25)

* update aws action to v2

* add testing branch

* add secrets: inherit to fix the workflow_call

* cosmetics: ready to go live
cnkang referenced this issue in cnkang/LibreChat Feb 6, 2024
* server-side JWT auth implementation

* move oauth routes and strategies, fix bugs

* backend modifications for wiring up the frontend login and reg forms

* Add frontend data services for login and registration

* Add login and registration forms

* Implment auth context, functional client side auth

* protect routes with jwt auth

* finish local strategy (using local storage)

* Start setting up google auth

* disable token refresh, remove old auth middleware

* refactor client, add ApiErrorBoundary context

* disable google and facebook strategies

* fix: fix presets not displaying specific to user

* fix: fix issue with browser refresh

* fix: casing issue with User.js (#11)

* delete user.js to be renamed

* fix: fix casing issue with User.js

* comment out api error watcher temporarily

* fix: issue with api error watcher (#12)

* delete user.js to be renamed

* fix: fix casing issue with User.js

* comment out api error watcher temporarily

* feat: add google auth social login

* fix: make google login url dynamic based on dev/prod

* fix: bug where UI is briefly displayed before redirecting to login

* fix: fix cookie expires value for local auth

* Update README.md

* Update LOCAL_INSTALL structure

* Add local testing instructions

* Only load google strategy if client id and secret are provided

* Update .env.example files with new params

* fix issue with not redirecting to register form

* only show google login button if value is set in .env

* cleanup log messages

* Add label to button for google login on login form

* doc: fix client/server url values in .env.example

* feat: add error message details to registration failure

* Restore preventing paste on confirm password

* auto-login user after registering

* feat: forgot password (#24)

* make login/reg pages look like openai's

* add password reset data services

* new form designs similar to openai, add password reset pages

* add api's for password reset

* email utils for password reset

* remove bcrypt salt rounds from process.env

* refactor: restructure api auth code, consolidate routes (#25)

* add api's for password reset

* remove bcrypt salt rounds from process.env

* refactor: consolidate auth routes, use controller pattern

* refactor: code cleanup

* feat: migrate data to first user (#26)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes after refactor (#27)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: issue with auto-login when logging out then logging in with new browser window (#28)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: Update README and .env.example files with user system information (#29)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: update README and .env.example files

* Fixup: LOCAL_INSTALL.md PS instructions (danny-avila#200) (#30)

Co-authored-by: alfredo-f <[email protected]>

* feat: send user with completion to protect against abuse (#31)

* Fixup: LOCAL_INSTALL.md PS instructions (danny-avila#200)

* server-side JWT auth implementation

* move oauth routes and strategies, fix bugs

* backend modifications for wiring up the frontend login and reg forms

* Add frontend data services for login and registration

* Add login and registration forms

* Implment auth context, functional client side auth

* protect routes with jwt auth

* finish local strategy (using local storage)

* Start setting up google auth

* disable token refresh, remove old auth middleware

* refactor client, add ApiErrorBoundary context

* disable google and facebook strategies

* fix: fix presets not displaying specific to user

* fix: fix issue with browser refresh

* fix: casing issue with User.js (#11)

* delete user.js to be renamed

* fix: fix casing issue with User.js

* comment out api error watcher temporarily

* feat: add google auth social login

* fix: make google login url dynamic based on dev/prod

* fix: bug where UI is briefly displayed before redirecting to login

* fix: fix cookie expires value for local auth

* Only load google strategy if client id and secret are provided

* Update .env.example files with new params

* fix issue with not redirecting to register form

* only show google login button if value is set in .env

* cleanup log messages

* Add label to button for google login on login form

* doc: fix client/server url values in .env.example

* feat: add error message details to registration failure

* Restore preventing paste on confirm password

* auto-login user after registering

* feat: forgot password (#24)

* make login/reg pages look like openai's

* add password reset data services

* new form designs similar to openai, add password reset pages

* add api's for password reset

* email utils for password reset

* remove bcrypt salt rounds from process.env

* refactor: restructure api auth code, consolidate routes (#25)

* add api's for password reset

* remove bcrypt salt rounds from process.env

* refactor: consolidate auth routes, use controller pattern

* refactor: code cleanup

* feat: migrate data to first user (#26)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes after refactor (#27)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: issue with auto-login when logging out then logging in with new browser window (#28)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: Update README and .env.example files with user system information (#29)

* refactor: use /api for auth routes

* fix: use user id instead of username

* feat: migrate data to first user on register

* fix: fix social login routes

* fix: fix issue with auto-login in new tab

* doc: update README and .env.example files

* Send user id to openai to protect against abuse

* add meilisearch to gitignore

* Remove webpack

---------

Co-authored-by: alfredo-f <[email protected]>

---------

Co-authored-by: Danny Avila <[email protected]>
Co-authored-by: Alfredo Fomitchenko <[email protected]>
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

No branches or pull requests

1 participant