dify icon indicating copy to clipboard operation
dify copied to clipboard

本地化部署注释掉 docker-compose.yaml 中的 nginx 部分,服务无法启动

Open ryzn0518 opened this issue 1 year ago • 14 comments

  1. 注释掉 nginx 部分 image

  2. 除了 nginx 其他服务都正常启动; image

  3. 但是在外部 curl http://127.0.0.1:3000 image

ryzn0518 avatar May 30 '23 06:05 ryzn0518

Is port 3000 listening?

zxhlyh avatar May 30 '23 07:05 zxhlyh

Is port 3000 listening?

啥意思?我看 docker ps -a 的时候,docker 容器是启动正常的。

ryzn0518 avatar May 30 '23 07:05 ryzn0518

docker ps -f "publish=3000"

zxhlyh avatar May 30 '23 07:05 zxhlyh

docker ps -f "publish=3000"

为空,好奇怪,这是为什么?谢谢。

ryzn0518 avatar May 30 '23 07:05 ryzn0518

web image should add ports configuration eg: ports: - "3000:3000"

zxhlyh avatar May 30 '23 08:05 zxhlyh

web image should add ports configuration eg: ports: - "3000:3000"

我试试,谢谢。

ryzn0518 avatar May 30 '23 09:05 ryzn0518

@zxhlyh 你好,能正常启动了。我执行 http://xxxx:3000/install 后,填写了一些信息,发现没有响应。

image

ryzn0518 avatar May 30 '23 11:05 ryzn0518

Due to the api needs to be redirected from nginx. I guess you want to develop locally. If so, please refer to this document. https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md

zxhlyh avatar May 30 '23 11:05 zxhlyh

Due to the api needs to be redirected from nginx. I guess you want to develop locally. If so, please refer to this document. https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md

你好,其实我不是为了开发,只是单纯的想本地部署 dify.

我之前注释 nginx 是因为部署的服务器已经有了 nginx,有冲突,所以,当前我停掉了服务器上的nginx,并且,重新把 docker-compose.yaml 里面的 nginx 部分注释的内容打开,同时增加了本机的 nginx.conf 映射地址

image

然后映射的 nginx.conf 里面的内容是

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;
    client_max_body_size 1000m;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
    server {
        listen       443 ssl;
        server_name  xxx.xx.xxx;
        root         /usr/share/nginx/html;

        ssl_certificate "/etc/ssl/xxxx.pem";
        ssl_certificate_key "/etc/ssl/xxx.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
}

重新启动 docker-compose up,看起来一切正常,服务也都正常启动,但是我远程访问对应的域名,却没有任何效果,浏览器显示: image

ryzn0518 avatar May 30 '23 14:05 ryzn0518

Please check your CONSOLE_URL, APP_URL, WEB_URL and CORS configuration is correct

JohnJyong avatar May 31 '23 02:05 JohnJyong

https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md

@zxhlyh @JohnJyong

你好,还是感觉不太懂到底应该怎么配置。我现在已经设置了 CONSOLE_URL, APP_URL,没有找到 WEB_URL 在 docker.compse.yaml 中这个字段,同时在 nginx.conf 中,增加了指定 location 但是还是没有任何效果; 不清楚到底应该怎么配置,能否帮忙给点指导,谢谢;

我还想补充的是,我们只有一个域名,所以 api 部分的域名映射和 web 部分的域名映射想通过路径区别,我感觉现在我最大的问题是不知道这里如何区分配置;

其中, api 部分的常量设置:xxx 是我们的域名; CONSOLE_URL: https://xxx/console/api APP_URL: https://xxx/app API_URL: 'https://xxx/api'

web 部分的常量设置: CONSOLE_URL: 'https://xxx/console/api' APP_URL: 'https://xxx/app'

location / {
                proxy_pass http://web:3000;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
            }
location /v1 {
        proxy_pass http://api:5001;
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
}

location /console/api {
        proxy_pass http://api:5001;
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
}

location /api {
        proxy_pass http://api:5001;
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
    }

我进入 docker container,执行,能看到服务是正常启动的才对; image

ryzn0518 avatar May 31 '23 04:05 ryzn0518

总结一下,所有的 docker-compose.yaml 中的那些 APP_URL,配置相同的域名,比如,这些都写成,https://my.domain.com

ryzn0518 avatar May 31 '23 09:05 ryzn0518

@zxhlyh 你好。现在install 的时候会遇到这个问题,这个是 nginx 里面的限制有问题,还是哪里有问题。 image

ryzn0518 avatar Jun 02 '23 06:06 ryzn0518

@zxhlyh 你好。现在install 的时候会遇到这个问题,这个是 nginx 里面的限制有问题,还是哪里有问题。 image

The app doesn't have this 403 error, it might be an issue with the nginx configuration. If you've made any changes to the config, or it was working fine before, please let us know so we can take a look.

takatost avatar Jun 03 '23 06:06 takatost