Skip to content

Development Environment Configuration #5

Closed

Description

@skywalker512

我按照你们的指南进行配置,但是遇到了一些问题

  1. 你们的指南中没有提到如何配置 web 的 .env.local 文件
# web/.env.local
NEXT_PUBLIC_DEPLOY_ENV=DEVELOPMENT
NEXT_PUBLIC_EDITION=SELF_HOSTED
NEXT_PUBLIC_API_PREFIX=http://127.0.0.1:5001/console/api
NEXT_PUBLIC_PUBLIC_API_PREFIX=http://127.0.0.1:5001/api
  1. docker/volumes/db/scripts 似乎有权限问题
    ls: can't open '/docker-entrypoint-initdb.d/': Permission denied

  2. 没有告诉用户需要在 http://localhost:3000/install 进行管理员配置

  3. CHECK_UPDATE_URL 需要访问你们的在线服务,在中国访问有些问题

Activity

  1. takatost commented on May 15, 2023

    @takatost
    Contributor
    1. 这个问题确实是权限问题,我们优先修一下这个
  2. takatost commented on May 15, 2023

    @takatost
    Contributor

    @skywalker512 问题 2 fixed
    重新部署前需要拉一下服务端最新镜像
    docker pull langgenius/dify-api:latest

  3. iamjoel commented on May 15, 2023

    @iamjoel
    Contributor

    关于 1

    1. NEXT_PUBLIC_DEPLOY_ENV: 开发环境。本地跑用设值为 DEVELOPMENT,生产环境设 PRODUCTION。
    2. NEXT_PUBLIC_EDITION: 写死值为 SELF_HOSTED。
    3. NEXT_PUBLIC_API_PREFIX:后台的接口前缀。
    4. NEXT_PUBLIC_PUBLIC_API_PREFIX:分享出去的 webapp 的接口前缀。
  4. muxuan1978 commented on May 15, 2023

    @muxuan1978

    部署成功了,可以配置保存,但是登录成功后先跳到/apps页面,过一会还是会跳转到登录页面signin

  5. takatost commented on May 15, 2023

    @takatost
    Contributor

    部署成功了,可以配置保存,但是登录成功后先跳到/apps页面,过一会还是会跳转到登录页面signin

    和 cookie 策略可能有关系,有修改过什么配置或者端口、域名吗?

    docker-compose.yml 中有这些配置和跨域策略、cookie 策略相关,可以尝试修改

          # Specifies the allowed origins for cross-origin requests to the Web API
          WEB_API_CORS_ALLOW_ORIGINS: http://localhost,*
          # Specifies the allowed origins for cross-origin requests to the console API
          CONSOLE_CORS_ALLOW_ORIGINS: http://localhost,*
          # CSRF Cookie settings
          # Controls whether a cookie is sent with cross-site requests,
          # providing some protection against cross-site request forgery attacks
          COOKIE_HTTPONLY: 'true'
          COOKIE_SAMESITE: 'None'
          COOKIE_SECURE: 'true'
    
  6. added
    🐞 bug
    📚 documentation
    on May 15, 2023
  7. jiangpengwz commented on May 15, 2023

    @jiangpengwz

    自定义域名,doker-compse.yml里所有localhost都已经修改为自定义域名。install和登陆时,通过控制台查看网络调用api,发现
    image
    也是bug么?

    额外信息,修改了docker-compose.yaml中,nginx的外部端口为81,然后通过宿主机的nginx做的域名转发到localhost:81。

  8. takatost commented on May 15, 2023

    @takatost
    Contributor

    自定义域名,doker-compse.yml里所有localhost都已经修改为自定义域名。install和登陆时,通过控制台查看网络调用api,发现 image 也是bug么?

    额外信息,修改了docker-compose.yaml中,nginx的外部端口为81,然后通过宿主机的nginx做的域名转发到localhost:81。

    Set-Cookie 处有个感叹号,应该和这个相关,可以看下是什么 warning 信息

  9. jiangpengwz commented on May 15, 2023

    @jiangpengwz

    image
    破案了,Secure是只能用在https上的。我吧COOKIE_SECURE 改成false就过了,但api502了。。。。

  10. MartialBE commented on May 15, 2023

    @MartialBE

    image 破案了,Secure是只能用在https上的。我吧COOKIE_SECURE 改成false就过了,但api502了。。。。

    http 这样设置:

    COOKIE_SAMESITE: 'Lax'
    COOKIE_SECURE: 'false'
    
    

    SameSite 为None时 Secure必须设置。

  11. takatost commented on May 15, 2023

    @takatost
    Contributor

    image 破案了,Secure是只能用在https上的。我吧COOKIE_SECURE 改成false就过了,但api502了。。。。

    可能需要重启下 nginx:

    docker restart <nginx container id>
    
  12. takatost commented on May 15, 2023

    @takatost
    Contributor

    image 破案了,Secure是只能用在https上的。我吧COOKIE_SECURE 改成false就过了,但api502了。。。。

    http 这样设置:

    COOKIE_SAMESITE: 'Lax'
    COOKIE_SECURE: 'false'
    

    SameSite 为None时 Secure必须设置。

    默认配置可能太严格了,我改宽松点看看

  13. muxuan1978 commented on May 15, 2023

    @muxuan1978

    改了上面说的Cookie参数后可以了

  14. takatost commented on May 15, 2023

    @takatost
    Contributor

    image 破案了,Secure是只能用在https上的。我吧COOKIE_SECURE 改成false就过了,但api502了。。。。

    可能需要重启下 nginx:

    docker restart <nginx container id>
    

    #23 改成了相对宽松的默认策略。

    • 默认策略

    适用于本地调试用,支持 HTTP/HTTPS 协议,但需要保证前端页面和接口同域。

    WEB_API_CORS_ALLOW_ORIGINS: '*'
    CONSOLE_CORS_ALLOW_ORIGINS: '*'
    COOKIE_HTTPONLY: 'true'
    COOKIE_SAMESITE: 'Lax'
    COOKIE_SECURE: 'false'
    
    • 跨域策略(请勿应在生产)

    由于 SameSite=None 必须配合 Secure=true,因此服务端必须为 https 协议才能实现跨域访问,可以用在服务端在远程并且提供 https 协议支持,或者本地单独启动服务端和前端项目(localhost,但不同端口,实测可用,虽然提示 warning)。

    WEB_API_CORS_ALLOW_ORIGINS: 'https://your-domain-for-web-app'
    CONSOLE_CORS_ALLOW_ORIGINS: 'https://your-domain-for-console'
    COOKIE_HTTPONLY: 'true'
    COOKIE_SAMESITE: 'None'
    COOKIE_SECURE: 'true'
    
    • 生产策略

    由于部分第三方集成需要支持回调并带着 cookie 信息,因此不能使用最高的 Strict 策略,因此需要严格限制 CORS 域名,以及设置 cookie 策略为 SameSite=Lax Secure=true。

    WEB_API_CORS_ALLOW_ORIGINS: 'https://your-domain-for-web-app'
    CONSOLE_CORS_ALLOW_ORIGINS: 'https://your-domain-for-console'
    COOKIE_HTTPONLY: 'true'
    COOKIE_SAMESITE: 'Lax'
    COOKIE_SECURE: 'true'
    

    另外,如果切换域名了,请将 docker-compose.yml 中所有的以下配置项改为新的域名:

    • CONSOLE_URL:控制台域名
    • API_URL:Service API 域名
    • APP_URL:Web APP 域名
  15. wangboak commented on May 16, 2023

    @wangboak

    #在 dify目录下,下载 docker-compose.yaml
    docker-compose up -d

    Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/host_mnt/Users/wangbo/soft/docker_app/dify/nginx/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": mount /host_mnt/Users/wangbo/soft/docker_app/dify/nginx/nginx.conf:/etc/nginx/nginx.conf (via /proc/self/fd/9), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type

    nginx 一直启动不起来,有知道是什么原因吗?

  16. takatost commented on May 16, 2023

    @takatost
    Contributor

    看起来是找不到文件,是否为 docker in docker 模式?没有把 host 目录挂载到 docker 对应目录?

  17. wangboak commented on May 16, 2023

    @wangboak

    看起来是找不到文件,是否为 docker in docker 模式?没有把 host 目录挂载到 docker 对应目录?

    已经解决了~ 我是直接下载了 docker-compose.yaml 这个文件,并 运行 docker-compose up -d 命令。
    并没有git clone 整个项目,并在docker目录下执行此命令。
    报错原因是 nginx运行所需的config文件不存在。

  18. renguowen commented on May 16, 2023

    @renguowen

    有遇到这个问题的吗,docker-compose up -d时报错ERROR: manifest for semitechnologies/weaviate:1.18.4 not found
    手动拉取docker pull semitechnologies/weaviate:1.18.4也不行还是报错Error response from daemon: manifest for semitechnologies/weaviate:1.18.4 not found

  19. takatost commented on May 16, 2023

    @takatost
    Contributor
  20. added a commit that references this issue on Jan 16, 2024
  21. added a commit that references this issue on Jul 11, 2025
  22. added a commit that references this issue on Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bug📚 documentation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions