memochou1993 / gpt-ai-assistant

OpenAI + LINE + Vercel = GPT AI Assistant
https://memochou1993.github.io/gpt-ai-assistant-docs/
MIT License
7.25k stars 9.36k forks source link

關於使用 Docker 部署的問題 #240

Closed joe94540712 closed 1 year ago

joe94540712 commented 1 year ago

使用 4.4.4 版本,並透過 docker 進行部署 同時設定 reverse proxy 後,可於 https://example.domain 中可以正常顯示 "OK" 而在 https://example.domain/info中也正常顯示 {"currentVersion":"4.4.4","latestVersion":"4.4.4"}

不過在line後臺設定webhook時,https://example.domain/webhook 輸入完成驗證時,卻顯示下圖錯誤: CleanShot 2023-03-27 at 21 59 07

有檢查 .env 中 Line 的兩個參數皆輸入正確

LINE_CHANNEL_ACCESS_TOKEN=exampleTOKEN$@##@exampleTOKEN
LINE_CHANNEL_SECRET=exampleSECRET$@##@exampleTOKEN

其他 .env 中也僅設定 port & OpenAI API,其餘皆留白 有參考 #202 類似的問題,不過 @tsu299 遇到的 ERROR 爲 500 不知道還有哪部分有疏漏的地方嗎?

tsu299 commented 1 year ago

可以貼下你reverse proxy 的設定嗎? 我後來設定沒遇到問題了

joe94540712 commented 1 year ago

可以貼下你 reverse proxy 的設定嗎?我後來設定沒遇到問題了

我是使用 nginx proxy manager設定的,並沒有特別調整什麼 但看起來 reverse proxy 部分應該沒問題才對(至少瀏覽器直接開啓網頁OK,要使用 Line webhook 時才出現Error)


server {
  set $forward_scheme http;
  set $server         "SERVER_NAME";
  set $port           3333;

  listen 80;
listen [::]:80;

listen 443 ssl http2;
listen [::]:443 ssl http2;

  server_name exmaple.domain;

  # Block Exploits
  include conf.d/include/block-exploits.conf;

    # Force SSL
    include conf.d/include/force-ssl.conf;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;

 access_log /logs/proxy-host-access.log proxy;
 error_log /logs/proxy-host-error.log warn;

  location / {
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;

    # Proxy!
    include conf.d/include/proxy.conf;
  }

  # Custom
  include /data/nginx/custom/server_proxy[.]conf;
}
joe94540712 commented 1 year ago

還是 line 設定裡面的 key 有需要 "" or <> 的引號嗎?

LINE_CHANNEL_ACCESS_TOKEN=exampleTOKEN$@##@exampleTOKEN
LINE_CHANNEL_SECRET=exampleSECRET$@##@exampleTOKEN
tsu299 commented 1 year ago

還是 line 設定裡面的 key 有需要 "" or <> 的引號嗎?

LINE_CHANNEL_ACCESS_TOKEN=exampleTOKEN$@##@exampleTOKEN
LINE_CHANNEL_SECRET=exampleSECRET$@##@exampleTOKEN

Key 不用引號,像你這樣輸入就可

tsu299 commented 1 year ago

你Nginx 得部份是跟docker在同一台server上嗎?

joe94540712 commented 1 year ago

你 Nginx 得部份是跟 docker 在同一台 server 上嗎?

對的,都是在同一臺機器上,不過方便管理才使用docker做部署

tsu299 commented 1 year ago

你 Nginx 得部份是跟 docker 在同一台 server 上嗎?

對的,都是在同一臺機器上,不過方便管理才使用docker做部署

那你把 你reverse proxy的這個.conf 改成這樣,不要使用include 去帶config, 自定義的部分跟證書位置記得更改

server {
    listen 80;
    server_name yourdomain;
    return 301 https://yourdomain;
}

server {
    listen 443 ssl;
    server_name yourdomain;
    ssl_certificate crt_file;
    ssl_certificate_key key_file;

    location / {
        proxy_pass http://localhost:port;
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X- Real - IP $remote_addr;
        proxy_set_header X - Scheme $scheme;
        proxy_set_header X - Forwarded - For $proxy_add_x_forwarded_for;
        proxy_set_header X - Forwarded - Proto $scheme;
}
    }