当前位置: 首页 > news >正文

长春网站建设外包在哪学短视频培训课程

长春网站建设外包,在哪学短视频培训课程,深圳网站建设哪个好,微服务网站开发背景 前面我们以 docker compose 容器化的方式本地部署了 Dify 社区版,并快速体验了其聊天助手、工作量编排以及智能体(Agent)功能。不过后续实际生产环境使用时遇到了忘记密码、如何开启SSL以支持HTTPS、如何突破知识库文档上传的大小限制和…

背景

前面我们以 docker compose 容器化的方式本地部署了 Dify 社区版,并快速体验了其聊天助手、工作量编排以及智能体(Agent)功能。不过后续实际生产环境使用时遇到了忘记密码如何开启SSL以支持HTTPS如何突破知识库文档上传的大小限制和数量限制等问题。

2024-12-28-DifyArchitecture.jpg

遇到的问题

本地部署初始化后,忘记密码、密码错误如何重置?

这个问题官方文档里有写,在服务器上执行以下命令进行密码重置。

docker exec -it docker-api-1 flask reset-password

输入账户 email 以及两次新密码即可。

Note:一开始我并不知道官方文档提供了密码重置的方案,当时的第一想法是使用测试环境的密码覆盖生产环境的密码即可,便有了以下操作。
通过 docker-compose.yaml 以及 docker ps ,我们知道 Dify 用的是 PostgreSQL 数据库,不过默认没有开启远程访问,下面通过命令行来操作 PostgreSQL 数据库。

# 命令行连接PostgreSQL
[root@dify ~]# docker exec -it docker_db_1 /bin/bash
c84995ae10f8:/# psql -U postgres
psql (15.10)
Type "help" for help.# 列出所有数据库
postgres=# \lList of databasesName    |  Owner   | Encoding |  Collate   |   Ctype    | ICU Locale | Locale Provider |   Access privileges   
-----------+----------+----------+------------+------------+------------+-----------------+-----------------------dify      | postgres | UTF8     | en_US.utf8 | en_US.utf8 |            | libc            | postgres  | postgres | UTF8     | en_US.utf8 | en_US.utf8 |            | libc            | template0 | postgres | UTF8     | en_US.utf8 | en_US.utf8 |            | libc            | =c/postgres          +|          |          |            |            |            |                 | postgres=CTc/postgrestemplate1 | postgres | UTF8     | en_US.utf8 | en_US.utf8 |            | libc            | =c/postgres          +|          |          |            |            |            |                 | postgres=CTc/postgres
(4 rows)# 切换到dify数据库
postgres=# \c dify
You are now connected to database "dify" as user "postgres".# 查看所有数据表
dify=# \dList of relationsSchema |               Name                |   Type   |  Owner   
--------+-----------------------------------+----------+----------public | account_integrates                | table    | postgrespublic | accounts                          | table    | postgrespublic | alembic_version                   | table    | postgrespublic | api_based_extensions              | table    | postgrespublic | api_requests                      | table    | postgrespublic | api_tokens                        | table    | postgrespublic | app_annotation_hit_histories      | table    | postgrespublic | app_annotation_settings           | table    | postgrespublic | app_dataset_joins                 | table    | postgrespublic | app_model_configs                 | table    | postgrespublic | apps                              | table    | postgrespublic | celery_taskmeta                   | table    | postgrespublic | celery_tasksetmeta                | table    | postgrespublic | conversations                     | table    | postgrespublic | data_source_api_key_auth_bindings | table    | postgrespublic | data_source_oauth_bindings        | table    | postgrespublic | dataset_collection_bindings       | table    | postgrespublic | dataset_keyword_tables            | table    | postgrespublic | dataset_permissions               | table    | postgrespublic | dataset_process_rules             | table    | postgrespublic | dataset_queries                   | table    | postgrespublic | dataset_retriever_resources       | table    | postgrespublic | datasets                          | table    | postgrespublic | dify_setups                       | table    | postgrespublic | document_segments                 | table    | postgrespublic | documents                         | table    | postgrespublic | embeddings                        | table    | postgrespublic | end_users                         | table    | postgrespublic | external_knowledge_apis           | table    | postgrespublic | external_knowledge_bindings       | table    | postgrespublic | installed_apps                    | table    | postgrespublic | invitation_codes                  | table    | postgrespublic | invitation_codes_id_seq           | sequence | postgrespublic | load_balancing_model_configs      | table    | postgrespublic | message_agent_thoughts            | table    | postgrespublic | message_annotations               | table    | postgrespublic | message_chains                    | table    | postgrespublic | message_feedbacks                 | table    | postgrespublic | message_files                     | table    | postgrespublic | messages                          | table    | postgrespublic | operation_logs                    | table    | postgrespublic | pinned_conversations              | table    | postgrespublic | provider_model_settings           | table    | postgrespublic | provider_models                   | table    | postgrespublic | provider_orders                   | table    | postgrespublic | providers                         | table    | postgrespublic | recommended_apps                  | table    | postgrespublic | saved_messages                    | table    | postgrespublic | sites                             | table    | postgrespublic | tag_bindings                      | table    | postgrespublic | tags                              | table    | postgrespublic | task_id_sequence                  | sequence | postgrespublic | taskset_id_sequence               | sequence | postgrespublic | tenant_account_joins              | table    | postgrespublic | tenant_default_models             | table    | postgrespublic | tenant_preferred_model_providers  | table    | postgrespublic | tenants                           | table    | postgrespublic | tidb_auth_bindings                | table    | postgrespublic | tool_api_providers                | table    | postgrespublic | tool_builtin_providers            | table    | postgrespublic | tool_conversation_variables       | table    | postgrespublic | tool_files                        | table    | postgrespublic | tool_label_bindings               | table    | postgrespublic | tool_model_invokes                | table    | postgrespublic | tool_providers                    | table    | postgrespublic | tool_published_apps               | table    | postgrespublic | tool_workflow_providers           | table    | postgrespublic | trace_app_config                  | table    | postgrespublic | upload_files                      | table    | postgrespublic | whitelists                        | table    | postgrespublic | workflow_app_logs                 | table    | postgrespublic | workflow_conversation_variables   | table    | postgrespublic | workflow_node_executions          | table    | postgrespublic | workflow_runs                     | table    | postgrespublic | workflows                         | table    | postgres
(75 rows)# 查看账户表
dify=# \d accountsTable "public.accounts"Column       |            Type             | Collation | Nullable |           Default           
--------------------+-----------------------------+-----------+----------+-----------------------------id                 | uuid                        |           | not null | uuid_generate_v4()name               | character varying(255)      |           | not null | email              | character varying(255)      |           | not null | password           | character varying(255)      |           |          | password_salt      | character varying(255)      |           |          | avatar             | character varying(255)      |           |          | interface_language | character varying(255)      |           |          | interface_theme    | character varying(255)      |           |          | timezone           | character varying(255)      |           |          | last_login_at      | timestamp without time zone |           |          | last_login_ip      | character varying(255)      |           |          | status             | character varying(16)       |           | not null | 'active'::character varyinginitialized_at     | timestamp without time zone |           |          | created_at         | timestamp without time zone |           | not null | CURRENT_TIMESTAMP(0)updated_at         | timestamp without time zone |           | not null | CURRENT_TIMESTAMP(0)last_active_at     | timestamp without time zone |           | not null | CURRENT_TIMESTAMP(0)
Indexes:"account_pkey" PRIMARY KEY, btree (id)"account_email_idx" btree (email)# 查询所有用户记录
dify=# select * from accounts;id                  | name  |       email       |                                         password                                         |      password_salt       | avatar | interface_language | interface_theme |     timezone     |       last_login_at        | last_login_ip  | status |       initialized_at       |     created_at      |     updated_at      |      last_active_at      
--------------------------------------+-------+-------------------+------------------------------------------------------------------------------------------+--------------------------+--------+--------------------+-----------------+------------------+----------------------------+----------------+--------+----------------------------+---------------------+---------------------+--------------------------78837d37-83d0-4e21-88c0-25de52df8ee0 | Admin | you-guess@qq.com | OTYyYjZmNWFlMWI2MzIyZTU3ZWMyMjNmOGEzY2E0OTkwYmYxMzNmN2MzMTM2M2IyMzZlM2M0MDQyOTAyM2E1MQ== | 4bGygMJ7I7w6CLVXpEeRrA== |        | en-US              | light           | America/New_York | 2024-12-07 08:24:27.715579 | 192.168.27.200 | active | 2024-12-07 08:24:06.685263 | 2024-12-07 08:24:07 | 2024-12-07 08:24:07 | 2024-12-22 08:00:40.2632
(1 row)

可以看到密码密文盐值信息。接着使用一个已知密码的密文和盐值更新到 accounts 表;

从测试环境服务器上导出了 SQLInsert 语句。

pg_dump -d dify -U postgres --column-inserts -t accounts -f /opt/accounts.sql

UPDATE public.accounts SET password='YmFjYWMwYWFkNTU2MDlmMmViNTZhNTc3N2JjZDBjMDk4ZWVmNjRjYjA2MGU4MzQ0YTZjNzViNjVhYzAyMzZhYg==', password_salt='j13XCIHXI4N2AK4yIJuggQ==' WHERE id='78837d37-83d0-4e21-88c0-25de52df8ee0';

改了密码密文和盐值后,依然登不上?

经过上述密码密文盐值信息的替换后,还是没登上,不过错误信息是密码错误次数超限(默认锁定24小时)。这是因为当时忘记密码后,尝试了多次导致密码锁定。考虑到 Dify 用了 Redis ,而且一版这种密码次数错误限制我们也是通过 Redis 来实现,这里推测是 Redis 中有个用户被锁定的待超时时间的 Key 。直接打开 Dify 源码查看,果然~

2024-12-28-RedisKey.jpg

找见了原因,直接连上 Redis ,删除这个 Key 即可。

[root@dify opt]# docker exec -it docker_redis_1 sh
/data # redis-cli
127.0.0.1:6379> keys *
1) "refresh_token:7d177d5971609013a2c8a5634ce49de1d488332bb5961d8d69ce1a371a3abdeac65d9010df7a6f1e7c73508cbd6733e0c27e2235999ca593192919678ab688b4"
2) "reset_password:account:78837d37-83d0-4e21-88c0-25de52df8ee0"
3) "account_refresh_token:78837d37-83d0-4e21-88c0-25de52df8ee0"
4) "login_error_rate_limit:you-guess@qq.com"# 查看过期时间,大概还剩23个多小时。。
127.0.0.1:6379> ttl login_error_rate_limit:you-guess@qq.com
(integer) 85202# 删除这个Key
127.0.0.1:6379> del login_error_rate_limit:you-guess@qq.com
(integer) 1

之后即可成功登录~~

本地部署80端口被占用应该如何解决?

一般的服务器上会有其他服务占用 80 端口,这时需要修改 .env 文件,指定 Nginx 暴露的端口。

# 编辑.env文件
EXPOSE_NGINX_PORT=9080
EXPOSE_NGINX_SSL_PORT=9443

如何开启SSL以支持HTTPS?

  • 同样是编辑 .env 文件,配置 NGINX_HTTPS_ENABLED=true 开启 HTTPS
  • 此外,还需要将证书文件放到 dify-main/docker/nginx/ssl 目录下,记得命名为 dify.crtdify.key
  • 然后 docker-compose down 停止服务,最后启动服务 docker-compose up -d 生效。
NGINX_HTTPS_ENABLED=true

2024-12-28-SSL.jpg
Note:

  1. 具体SSL的配置是参考docker-compose.yaml里面的环境变量得到的;
  2. 关于如何自签证书,参考:自签SSL证书配置Nginx代理Vue+SpringBoot前后端分离服务。

如何解决知识库文档上传的大小限制和数量限制?

同样是编辑 .env 文件, Dify 知识库文档上传单个文档最大是 15MB ,总文档数量限制 100 个。本地部署的社区版本可根据需要调整修改该限制。

# 上传文件大小限制,默认15M。
UPLOAD_FILE_SIZE_LIMIT=50M# 每次上传文件数上限,默认5个。
UPLOAD_FILE_BATCH_LIMIT=10

小总结

本文主要介绍了 Dify 本地部署后遇到的几个常见问题及其解决方案:首先是忘记密码的处理,可以通过官方提供的 flask reset-password 命令重置,或者直接操作 PostgreSQL 数据库修改密码信息;其次是密码错误次数超限导致账户锁定的问题,可以通过删除 Redis 中对应的限制 Key 来解决;再次是端口占用和 HTTPS 配置问题,可以通过修改 .env 文件中的 EXPOSE_NGINX_PORTNGINX_HTTPS_ENABLED 等配置来解决;最后介绍了如何通过调整 .env 文件中的 UPLOAD_FILE_SIZE_LIMITUPLOAD_FILE_BATCH_LIMIT 参数来突破知识库文档上传的大小限制和数量限制。

Reference

  • https://docs.dify.ai/zh-hans

If you have any questions or any bugs are found, please feel free to contact me.

Your comments and suggestions are welcome!

http://www.yayakq.cn/news/659205/

相关文章:

  • 做招聘信息的网站有哪些全球最好的域名注册公司
  • 如何在百度里做推广网站如何提升网站alexa排名
  • 建站工具箱 discuz城市建设模拟游戏网站中文注解
  • 济南物流公司网站建设网站二次开发没人做
  • 网站介绍怎么写范文wordpress云建站教程视频
  • 各主流网站做景区宣传网站怎么制作小程序
  • 一站式平台网站开发技术wordpress编辑器媒体库
  • 保险微网站制作智慧校园学生管理系统
  • 网站添加在线支付wordpress菜单移到右边
  • 做电商网站的框架结构图重庆建设网站哪里好
  • 桂林北站是哪个区河南省和建设厅网站
  • 沈阳专业网站制作设计汽车专业科技网站建设
  • 郑州租赁房网站建设做招聘信息的网站
  • 静态网站建设的技术运用网站建设单子
  • 邵东做网站的公司wordpress文字头像
  • 网站建设与维护协议自己做网站需要做啥
  • 广西网站建设产品介绍市场调研的方法有哪些
  • 儋州市住房和城乡建设局官方网站asp网站建设外文参考文献
  • 杭州雄飞网站建设网络公司三站合一网站营销
  • 厦门人才网唯一官方网站wordpress论坛模板
  • 建站公司怎么获客虚拟主机装2个wordpress
  • wordpress如何把网站语言改成英文买域名做网站推广都是些什么
  • 南阳网站排名价格一个网站多少钱?
  • 成都网站制作培训多少钱wordpress还原网站源码
  • 传媒建站推荐西安网站制作设计找哪家
  • 免费域名网站的广州开发区第二小学
  • 网站流量的重要性网站建设情况登记表
  • 军用棉被门网站建设山东网站建设和游戏开发的公司
  • 网站建设被骗维护费上海定制网站开发营销推广
  • 江苏建设监理协会网站企业网站开发模型图