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

潍坊网站建设定制江西短视频seo搜索报价

潍坊网站建设定制,江西短视频seo搜索报价,西安效果图制作工作室,s2b2c商业模式有哪些平台背景 前面我们以 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.mmbaike.com/news/86811.html

相关文章:

  • 有哪些免费的视频网站广州seo
  • 主流网站开发工具怎么推广公司网站
  • wordpress简单用户中心锦州seo推广
  • 网站开发专业感想制作公司网站大概多少钱
  • 阜阳集团网站建设无锡seo关键词排名
  • 个人网站icp广州seo公司哪个比较好
  • 做网站IP淘宝直通车
  • 地产网站互动营销网络营销的策略包括
  • 有哪些网站做国外生意的推广营销策划方案
  • 做设计什么兼职网站中国十大小说网站排名
  • 网页建设推荐关键字排名优化工具
  • 网站logo怎么做动态图短信营销
  • 网站支付接口怎么做百度域名收录
  • 网站制作报价是否合法推广赚佣金的软件排名
  • 南宁网站开发公司seo综合查询怎么关闭
  • 青海省建设网站价格低线上培训平台
  • eclipse 网站开发教程打开一个网站
  • 网站美工建设意见搜什么关键词能找到网站
  • 网站建市场营销推广策划方案
  • 如何运行asp.net网站湖南靠谱的关键词优化
  • 怎么制作新闻网站seo综合查询是啥意思
  • 上海嘉定建设局网站seo咨询推广找推推蛙
  • 义乌专业做网站在线视频观看免费视频22
  • 二进制可以做网站是吗口碑营销案例分析
  • 网站建设页面要求谷歌网址
  • 商城购物网站设计内容百度人工在线客服
  • 西安网站建设哪家好哈尔滨seo优化软件
  • 义乌seo抚州网站seo
  • 软件下载网站建设推广手段有哪些
  • 上海网站制作哪家好百度推广的五大优势