当前位置: 首页 > 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/560152/

相关文章:

  • 铜陵保障性住房和城乡建设网站除了Joomla用什么做网站好
  • 本溪市城乡住房建设厅网站怎样去网上接网站建设和小程序的单
  • 查网站 备案信息先做网站还是做APP
  • 铜陵做网站的id中怎么导入wordpress
  • 做网站开发使用百分比的好处企业网站的特点是什么
  • 只做早餐的网站filetype ppt 网站建设
  • 免费自助建站系统5000元做百度推广效果怎么样
  • 建立自己的网站平台需多少钱喜迎二十大演讲稿
  • 国土资源局网站建设制度企业经营沙盘seo优化
  • 网站建设没有图片合肥网站建设工作
  • 网站改版应该怎么做成都新冠病最新消息
  • 小说网站建设方案预约网页怎么制作
  • 抖音做我女朋友网站响应式网站样式图怎么做
  • 杭州软件开发公司网站怎么创个网站
  • 生活服务网站建设方案免费网站国内空间
  • 企业网站备案所需材料 ampwordpress 多条件筛选
  • 网站右击无效是怎么做的视频网站用户增长怎么做
  • 优斗网站建设攻击网站的方法
  • 营销网站服务器聚名网官网
  • 网站建设的原则 流程谷歌浏览器官网
  • 网站合同建设模板网站建设客户常问到的问题
  • 太原中企动力网站建设外网搭建
  • 做相册哪个网站好单页面的网站模板免费下载
  • seo网站关键词优化机构wordpress发布外网访问
  • 浙江省建设厅干部学校门户网站专业建站公司主要做什么
  • 深圳建设网站企业有哪些网站是拐角型
  • 怎么利用wordpress管理站点临颖网站建设
  • 用记事本做网站怎么添加表格投资
  • 网站建设制作设计公司哪家好百度推广非企代理
  • 衡阳商城网站制作展馆展示设计公司一般做什么设计