http – 永夜 https://www.shuijingwanwq.com 没有不值得去解决的问题,也没有不值得去学习的技术! Sat, 30 May 2026 09:12:39 +0000 zh-Hans hourly 1 https://wordpress.org/?v=7.0 Google网页无法编入索引?我这样解决了 https://www.shuijingwanwq.com/2026/05/21/12363/ https://www.shuijingwanwq.com/2026/05/21/12363/#respond Thu, 21 May 2026 04:42:47 +0000 https://www.shuijingwanwq.com/?p=12363 Post Views: 27

1、收到 Google Search Console 的邮件:新原因导致网站 http://www.shuijingwanwq.com/ 上的网页无法被编入索引。如图1

收到 Google Search Console 的邮件:新原因导致网站 http://www.shuijingwanwq.com/ 上的网页无法被编入索引。如图1

2、打开索引编制报告,未被编入索引的网页有 863 个。原因为网页会自动重定向的网页就有 793 个。决定解决掉此问题。如图2

打开索引编制报告,未被编入索引的网页有 863 个。原因为网页会自动重定向的网页就有 793 个。决定解决掉此问题。如图2

3、点击 网页会自动重定向,此类网页未编入索引或不会显示在 Google 搜索结果中。点击某个示例网址的检查网址。如图3

点击 网页会自动重定向,此类网页未编入索引或不会显示在 Google 搜索结果中。点击某个示例网址的检查网址。如图3

4、网址尚未收录到 Google 。此网页未编入索引。未编入索引的网页无法显示在 Google 搜索结果中。请查看下述详情,了解为何没有编入索引。当时所用的用户代理 Googlebot 智能手机版。基于用户代理,我大概明白了原因。原因在于 https://www.shuijingwanwq.com/2017/09/11/1906/ 在手机中打开,会自动跳转至 https://www.shuijingwanwq.com/2017/09/11/1906/amp/ 。如图4

网址尚未收录到 Google 。此网页未编入索引。未编入索引的网页无法显示在 Google 搜索结果中。请查看下述详情,了解为何没有编入索引。当时所用的用户代理 Googlebot 智能手机版。基于用户代理,我大概明白了原因。原因在于 https://www.shuijingwanwq.com/2017/09/11/1906/ 在手机中打开,会自动跳转至 https://www.shuijingwanwq.com/2017/09/11/1906/amp/

5、根源在于 启用了 AMP for WP – Accelerated Mobile Pages for WordPress 插件。原本是希望通过启用此插件,增加 Google 的广告收入,后来发现不如预期。最终决定禁用此插件。如图5

根源在于 启用了 AMP for WP - Accelerated Mobile Pages for WordPress 插件。原本是希望通过启用此插件,增加 Google 的广告收入,后来发现不如预期。最终决定禁用此插件。如图5

6、然后等待一段时间,以观察网页索引效果。发现等待至 7月10日仍然没有效果。网页会自动重定向,点击验证修正情况,查看验证详情。如图6

然后等待一段时间,以观察网页索引效果。发现等待至 7月10日仍然没有效果。网页会自动重定向,点击验证修正情况,查看验证详情。如图6

7、到了 2024/07/25 ,提示 验证失败 开始日期:2024/7/10 失败日期:2024/7/13。如图7

到了 2024/07/25 ,提示 验证失败 开始日期:2024/7/10 失败日期:2024/7/13。如图7

8、查看详情,但是尝试在手机上打开网址,确定是不会自动重定向了的。决定再次验证,验证已开始 开始日期:2024/7/25 站点地图:所有已知网页。如图8

查看详情,但是尝试在手机上打开网址,确定是不会自动重定向了的。决定再次验证,验证已开始 开始日期:2024/7/25 站点地图:所有已知网页。如图8

9、在几天之后,收到邮件:关于网站 http://www.shuijingwanwq.com/ 上的还有一些网页索引编制问题未修正 问题。如图9

在几天之后,收到邮件:关于网站 http://www.shuijingwanwq.com/ 上的还有一些网页索引编制问题未修正 问题。如图9

10、查看问题详情,失败:241。如图10

11、最后,我终于发现了问题。原因是我的网站已经是全面支持 https 了。所有的 http 页面皆会自动跳转至 https。最后,我决定删除掉 http://www.shuijingwanwq.com/ 。仅保留 https://www.shuijingwanwq.com/ ,不过尴尬的是,删除后,竟然会自动增加了。如图11

最后,我终于发现了问题。原因是我的网站已经是全面支持 https 了。所有的 http 页面皆会自动跳转至 https。最后,我决定删除掉 http://www.shuijingwanwq.com/ 。仅保留 https://www.shuijingwanwq.com/ ,不过尴尬的是,删除后,竟然会自动增加了。如图11

12、我怀疑自动添加了 http://www.shuijingwanwq.com 。是否因为我网站内部还有链接指向 http://www.shuijingwanwq.com 了?GSC 会自动为 Googlebot 能找到的网址添加对应的资源。如果 Googlebot 在抓取 https://www.shuijingwanwq.com 时,发现网站内有任何指向 http:// 版本的链接,它就会顺藤摸瓜找到那个 http 页面,并在 GSC 里自动为你添加一个对应的资源。

13、我决定在后台 所有文章中 搜索 http://www.shuijingwanwq.com 。然后全部替换为 https://www.shuijingwanwq.com 。我在后台 所有文章中搜索 ,竟然有 300 多篇文章包含了 http://www.shuijingwanwq.com 。这个数量也太多了。决定使用插件 Better Search Replace。批量替换了。如图12

我决定在后台 所有文章中 搜索 http://www.shuijingwanwq.com 。然后全部替换为 https://www.shuijingwanwq.com 。我在后台 所有文章中搜索 ,竟然有 300 多篇文章包含了 http://www.shuijingwanwq.com 。这个数量也太多了。决定使用插件 Better Search Replace。批量替换了。如图12

14、模拟运行:共扫描了 25 张表,发现 6131 个待更新单元格,未进行任何更改。点击此处查看更多详情,或使用下方表单执行查找/替换操作。如图13

模拟运行:共扫描了 25 张表,发现 6131 个待更新单元格,未进行任何更改。点击此处查看更多详情,或使用下方表单执行查找/替换操作。如图13

15、点击 Click here,发现主要是以下表:wp_comments(17)、wp_options(3)、wp_postmeta(9)、wp_posts(1063)、wp_yoast_indexable(14)、wp_yoast_seo_links(5025)。如图14

点击 Click here,发现主要是以下表:wp_comments(17)、wp_options(3)、wp_postmeta(9)、wp_posts(1063)、wp_yoast_indexable(14)、wp_yoast_seo_links(5025)。如图14

16、执行数据库备份后,在 Better Search Replace 插件页面,取消勾选 Run as dry run。

保持其他选项不变(搜索/替换字符串、勾选的所有表)。

点击 “运行搜索/替换”。

等待页面执行完毕。你会看到类似 “共更改了 6131 个单元格” 的成功提示。如图15

点击 “运行搜索/替换”。

等待页面执行完毕。你会看到类似 “共更改了 6131 个单元格” 的成功提示。如图15

17、在后台 所有文章中 搜索 http://www.shuijingwanwq.com 。搜索结果为空。如图16

在后台 所有文章中 搜索 http://www.shuijingwanwq.com 。搜索结果为空。如图16

18、清除所有缓存。如图17

清除所有缓存。如图17

19、再次 设置 – 关于 – 移除资源 http://www.shuijingwanwq.com 。如图18

再次 设置 - 关于 - 移除资源 http://www.shuijingwanwq.com 。如图18

20、几天之后,确认 http://www.shuijingwanwq.com/ 不会自动增加,符合预期。

]]>
https://www.shuijingwanwq.com/2026/05/21/12363/feed/ 0
Mixed Content 导致网站页面错乱?一次 ISC 项目的完整排查与修复 https://www.shuijingwanwq.com/2026/03/25/9376/ https://www.shuijingwanwq.com/2026/03/25/9376/#respond Wed, 25 Mar 2026 06:31:08 +0000 https://www.shuijingwanwq.com/?p=9376 Post Views: 113

1、网站界面错乱,打开开发者工具 – 网络 – 全部。然后刷新网页,查看网络请求。发现样式文件的状态为:(已屏蔽:mixed-content)。如图1

网站界面错乱,打开开发者工具 - 网络 - 全部。然后刷新网页,查看网络请求。发现样式文件的状态为:(已屏蔽:mixed-content)。

2、但是,将状态为:(已屏蔽:mixed-content) 的 css 文件的网址在新标签页中打开,状态是 200。如图2

但是,将状态为:(已屏蔽:mixed-content) 的 css 文件的网址在新标签页中打开,状态是 200

3、为什么会出现 (已屏蔽: mixed-content)

网站是:

👉 https://www.jammerfromchina.com

但页面里加载的 CSS 是:

👉 http://xxx.css(注意是 http)

浏览器安全策略是这样的:

HTTPS 页面
❌ 不允许加载 HTTP 资源(CSS / JS / 图片)

否则就会:
👉 直接拦截(blocked:mixed-content)

所以看到:

状态:(已屏蔽:mixed-content)

4、为什么“单独打开 CSS 是 200”?

这个也很好理解:

在新标签打开:
👉 http://xxx.css

这是一个独立 HTTP 请求

浏览器不会限制 → 返回 200 ✅

但:

❗ 在 HTTPS 页面里引用 HTTP 资源 → 被拦截

5、查看网页源代码,搜索:Styles/styles.css,发现引用网址为:http://www.jammerfromchina.com/templates/__master/Styles/styles.css 。

6、ISC(Interspire Shopping Cart)是一款老牌 PHP+MySQL 商业电商系统,2012 年已官方停更,核心定位是轻量、易用、快速建站,曾是 Magento、ZenCart 的有力竞品。编辑配置文件 /config/config.php,http: 替换为 https:

<?php

        $GLOBALS['ISC_CFG']["ShopPath"] = 'https://www.jammerfromchina.com';

7、刷新页面,界面已经正常。打开开发者工具 – 网络 – 全部。然后刷新网页,查看网络请求。发现样式文件的状态为:200。如图3

刷新页面,界面已经正常。打开开发者工具 - 网络 - 全部。然后刷新网页,查看网络请求。发现样式文件的状态为:200
]]>
https://www.shuijingwanwq.com/2026/03/25/9376/feed/ 0
将一段捕获的 HTTP 请求体中的 \n 批量清除的实现 https://www.shuijingwanwq.com/2023/12/05/8257/ https://www.shuijingwanwq.com/2023/12/05/8257/#respond Tue, 05 Dec 2023 02:15:03 +0000 https://www.shuijingwanwq.com/?p=8257 Post Views: 73 1、在代理软件中捕获的 HTTP 请求体中包含大量的 \n 。如图1
在代理软件中捕获的 HTTP 请求体中包含大量的 \n

图1



{
  "query": "\n  query getApp($apiKey: String!) {\n    app(apiKey: $apiKey) {\n      applicationUrl\n      redirectUrlWhitelist\n      appProxy {\n        url\n        subPath\n        subPathPrefix\n      }\n    }\n  }\n",
  "variables": {
    "apiKey": "b1872dbbd62320f17101f477a56d6f6e"
  },
  "operationName": "getApp"
}


2、参考:在线文本内容关键词批量删除 – 过滤清除  。在关键词列表中输入:\\n,然后点击处理。处理后的结果如下,符合预期。如图2
参考:在线文本内容关键词批量删除 - 过滤清除 。http://www.txttool.com/t/?id=NTM5 。在关键词列表中输入:\\n,然后点击处理。处理后的结果如下,符合预期

图2



{
  "query": "  query getApp($apiKey: String!) {    app(apiKey: $apiKey) {      applicationUrl      redirectUrlWhitelist      appProxy {        url        subPath        subPathPrefix      }    }  }",
  "variables": {
    "apiKey": "b1872dbbd62320f17101f477a56d6f6e"
  },
  "operationName": "getApp"
}


3、最后在 GraphQL CLI 客户端中使用 美化,最终的请求符合预期。如图3
最后在 GraphQL CLI 客户端中使用 美化,最终的请求符合预期

图3



query getApp($apiKey: String!) {
  app(apiKey: $apiKey) {
    applicationUrl
    redirectUrlWhitelist
    appProxy {
      url
      subPath
      subPathPrefix
    }
  }
}



]]>
https://www.shuijingwanwq.com/2023/12/05/8257/feed/ 0
在 Windows 10 中安装 Wireshark 后对 Shopify CLI 3.x 的抓包流程 https://www.shuijingwanwq.com/2023/11/24/8225/ https://www.shuijingwanwq.com/2023/11/24/8225/#respond Fri, 24 Nov 2023 01:57:48 +0000 https://www.shuijingwanwq.com/?p=8225 Post Views: 123 1、参考:在 Windows 10 中安装 Fiddler Classic 后对 Shopify CLI 3.x 的抓包流程 。参考:在 Windows 10 中安装 Fiddler Everywhere 后对 Shopify CLI 3.x 的抓包流程。皆以失败告终。 2、选择网络接口:从 Wireshark 主窗口中,选择 Shopify CLI 流量将通过的网络接口。 由于我的是笔记本电脑,通过 Wi-Fi 连接网络,因此选择 WLAN,点击按钮:开始捕获分组。如图1
选择网络接口:从 Wireshark 主窗口中,选择 Shopify CLI 流量将通过的网络接口。 由于我的是笔记本电脑,通过 Wi-Fi 连接网络,因此选择 WLAN,点击按钮:开始捕获分组

图1

3、在终端中执行中 Shopify CLI 的命令,以请求获取主题列表。如图2
在终端中执行中 Shopify CLI 的命令,以请求获取主题列表

图2



PS E:\wwwroot\shopify-theme\theme-20230922> shopify theme list --verbose
2023-10-09T08:05:28.924Z: Running command theme list
2023-10-09T08:05:28.955Z: Ensuring that the user is authenticated with the Theme API with the following scopes:
[]

2023-10-09T08:05:28.956Z: Ensuring that the user is authenticated with the Admin API with the following scopes for the store shuijingwanwq-development.myshopify.com:
[]

2023-10-09T08:05:28.958Z: Getting session store...
2023-10-09T08:05:28.965Z: Validating existing session against the scopes:
[
  "openid",
  "https://api.shopify.com/auth/shop.admin.graphql",
  "https://api.shopify.com/auth/shop.admin.themes",
  "https://api.shopify.com/auth/partners.collaborator-relationships.readonly",
  "https://api.shopify.com/auth/shop.storefront-renderer.devtools",
  "https://api.shopify.com/auth/partners.app.cli.access",
  "https://api.shopify.com/auth/destinations.readonly"
]
For applications:
{
  "adminApi": {
    "scopes": [],
    "storeFqdn": "shuijingwanwq-development.myshopify.com"
  }
}

2023-10-09T08:05:28.967Z: Sending Identity Introspection request to URL: https://accounts.shopify.com/oauth/introspection
2023-10-09T08:05:28.969Z: Sending POST request to URL https://accounts.shopify.com/oauth/introspection
With request headers:
 - User-Agent: Shopify CLI; v=3.49.3
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: win32
 - Content-Type: application/json

2023-10-09T08:05:30.037Z: Request to https://accounts.shopify.com/oauth/introspection completed in 1044 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"7d98625ff90e9b2d78e0e2a444b14481"
 - x-request-id: 72585f47-91c2-4944-81b7-8349d2ab8cbf

2023-10-09T08:05:30.057Z: The identity token is valid: true
2023-10-09T08:05:30.058Z:
The validation of the token for application/identity completed with the following results:
- It's expired: false
- It's invalid in identity: false

2023-10-09T08:05:31.155Z: Request to https://shuijingwanwq-development.myshopify.com/admin/api/unstable/themes.json?fields=id%2Cname%2Crole%2Cprocessing completed in 1089 ms
With response headers:
 - content-type: application/json; charset=utf-8
 - x-request-id: bb9a9fa0-d8e7-4374-ba47-4d9a6c0b10d0

2023-10-09T08:05:31.166Z: Getting development theme...
2023-10-09T08:05:31.170Z: Getting host theme...
name                                             role                   id
───────────────────────────────────────────────  ─────────────────────  ─────────────
Dawn 的更新版副本                                      [live]                 #133644189881
Dawn                                             [unpublished]          #130440429753
Sense                                            [unpublished]          #130698641593
Crave 重命名                                        [unpublished]          #130935947449
Refresh                                          [unpublished]          #131376218297
Colorblock                                       [unpublished]          #131376251065
Dawn Customize                                   [unpublished]          #130580054201
Taste 的更新版副本 的更新版副本 的更新版副本 的更新版副本 的更新版副本 的更新版副本 [unpublished]          #132350771385

shopify-theme-dawn-20221011/main                 [unpublished]          #133060722873
Dawn                                             [unpublished]          #133474844857
Copy of Studio                                   [unpublished]          #133474975929
Dawn (Shopify CLI) 9                             [unpublished]          #133492932793
Dawn 的副本 的副本 1                                   [unpublished]          #133635932345
Colorblock                                       [unpublished]          #130698510521
Taste                                            [unpublished]          #130698543289
Craft                                            [unpublished]          #130698576057
Development (639b5c-DESKTOP-QLPK8QM)             [development] [yours]  #134109462713
2023-10-09T08:05:31.442Z:
Running system process:
  · Command: ruby -v
  · Working directory: E:/wwwroot/shopify-theme/theme-20230922

2023-10-09T08:05:33.063Z: Request to https://monorail-edge.shopifysvc.com/v1/produce completed in 1582 ms
With response headers:
 - x-request-id: 73b18bad-4378-4711-b2de-05386d867fa3

2023-10-09T08:05:33.066Z: Analytics event sent: {
  "command": "theme list",
  "time_start": 1696838728927,
  "time_end": 1696838731391,
  "total_time": 2464,
  "success": true,
  "cli_version": "3.49.3",
  "ruby_version": "3.1.1",
  "node_version": "18.18.0",
  "is_employee": false,
  "uname": "windows amd64",
  "env_ci": false,
  "env_plugin_installed_any_custom": false,
  "env_plugin_installed_shopify": "[\"@shopify/cli\",\"@shopify/plugin-did-you-mean\",\"@shopify/theme\"]",
  "env_shell": "cmd.exe",
  "env_device_id": "eb479d42673daf065d783e808d3de3b4870a4c02",
  "env_cloud": "localhost",
  "env_package_manager": "unknown",
  "cmd_all_launcher": "unknown",
  "cmd_all_topic": "theme",
  "cmd_all_plugin": "@shopify/theme",
  "cmd_all_verbose": true,
  "cmd_all_path_override": false,
  "args": "--verbose",
  "env_plugin_installed_all": "[\"@shopify/cli\",\"@shopify/plugin-did-you-mean\",\"@shopify/theme\"]",
  "metadata": "{\"extraPublic\":{},\"extraSensitive\":{}}"
}
2023-10-09T08:05:33.071Z: Completed command theme list
PS E:\wwwroot\shopify-theme\theme-20230922>


4、点击按钮:停止捕获分组。如图3
点击按钮:停止捕获分组

图3

5、通过 ping shuijingwanwq-development.myshopify.com 获取到对应的 IP 地址:23.227.38.74。如图4
通过 ping shuijingwanwq-development.myshopify.com 获取到对应的 IP 地址:23.227.38.74

图4



PS E:\wwwroot\shopify-theme\theme-20230922> ping shuijingwanwq-development.myshopify.com

正在 Ping shops.myshopify.com [23.227.38.74] 具有 32 字节的数据:
来自 23.227.38.74 的回复: 字节=32 时间=207ms TTL=50
来自 23.227.38.74 的回复: 字节=32 时间=209ms TTL=50
来自 23.227.38.74 的回复: 字节=32 时间=250ms TTL=50
来自 23.227.38.74 的回复: 字节=32 时间=204ms TTL=50

23.227.38.74 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 204ms,最长 = 250ms,平均 = 217ms


6、在 Source 中找到:23.227.38.74,右键 – 作为过滤器应用 – 选中。如图5
在 Source 中找到:23.227.38.74,右键 - 作为过滤器应用 - 选中

图5

7、仅剩下 Source 为 23.227.38.74 的请求记录。协议中竟然不存在 HTTP,是 TCP 与 TLSv1.3,并且响应是密文。如图6
仅剩下 Source 为 23.227.38.74 的请求记录。协议中竟然不存在 HTTP,是 TCP 与 TLSv1.3,并且响应是密文

图6

8、参考:Transport Layer Security (TLS)。密钥日志文件是一种通用机制,即使正在使用 Diffie-Hellman (DH) 密钥交换,它也始终能够解密。 9、添加 SSLKEYLOGFILE 用户变量,可以指定浏览器在访问 SSL/TLS 网站时将对应的密钥保存到本地文件中,其值为:E:\Develop\SSLKEYLOGFILE\key.log。此机制目前(2019 年)不适用于 Safari、Microsoft Edge 和其他浏览器,因为它们的 TLS 库(Microsoft SChannel/Apple SecureTransport)不支持此机制。 此机制也适用于 Web 浏览器以外的应用程序,但它依赖于应用程序使用的 TLS 库。注意:基于 Chrom 的 Edge 版本(版本 79+)也应该可以工作。如图7
添加 SSLKEYLOGFILE 用户变量,可以指定浏览器在访问 SSL/TLS 网站时将对应的密钥保存到本地文件中,其值为:E:\Develop\SSLKEYLOGFILE\key.log。此机制目前(2019 年)不适用于 Safari、Microsoft Edge 和其他浏览器,因为它们的 TLS 库(Microsoft SChannel/Apple SecureTransport)不支持此机制。 此机制也适用于 Web 浏览器以外的应用程序,但它依赖于应用程序使用的 TLS 库。注意:基于 Chrom 的 Edge 版本(版本 79+)也应该可以工作

图7

10、配置 Wireshark,编辑 – 首选项 – Protocls – TLS。(Pre)-Master-Secret 日志文件名 (tls.keylog_file):读取 TLS 密钥日志文件以进行解密的路径。TLS 调试文件 (tls.debug_logfile):写入有关解密过程的内部详细信息的路径。 将包含解密结果以及此过程中使用的密钥。 这可以用来诊断解密失败的原因。如图8
配置 Wireshark,编辑 - 首选项 - Protocls - TLS。(Pre)-Master-Secret 日志文件名 (tls.keylog_file):读取 TLS 密钥日志文件以进行解密的路径。TLS 调试文件 (tls.debug_logfile):写入有关解密过程的内部详细信息的路径。 将包含解密结果以及此过程中使用的密钥。 这可以用来诊断解密失败的原因

图8

11、启用 TLS 解密还需要以下 TCP 协议首选项:Allow subdissector to reassemble TCP streams(允许细分器重新组装 TCP 流)。 默认启用。Reassemble out-of-order segments(重新组装无序段)(从 Wireshark 3.0 开始,默认禁用)需要启用。如图9
启用 TLS 解密还需要以下 TCP 协议首选项:Allow subdissector to reassemble TCP streams(允许细分器重新组装 TCP 流)。 默认启用。Reassemble out-of-order segments(重新组装无序段)(从 Wireshark 3.0 开始,默认禁用)需要启用

图9

12、确认浏览器已被完全关闭,可通过查看任务管理器再次确认。在终端中执行了相应命令后,查看捕获的流量,仍然与第 7 步骤类似,TLS 没有被解密。虽然两个日志的更新时间发生了变化。如图10
确认浏览器已被完全关闭,可通过查看任务管理器再次确认。在终端中执行了相应命令后,查看捕获的流量,仍然与第 7 步骤类似,TLS 没有被解密。虽然两个日志的更新时间发生了变化

图10

13、不过在 Chrome 浏览器中访问:shuijingwanwq-development.myshopify.com 。查看捕获的流量,已经显示为 HTTP3,虽然仍然是密文。不符合预期。如图11
不过在 Chrome 浏览器中访问:shuijingwanwq-development.myshopify.com 。查看捕获的流量,已经显示为 HTTP3,虽然仍然是密文。不符合预期

图11

14、现在需要解密 HTTP3,在浏览器中导出 证书。如图12
现在需要解密 HTTP3,在浏览器中导出 证书

图12

15、配置 Wireshark,编辑 – 首选项 – Protocls – TLS。决定暂时搁置此方案,因为已经找到了更为合适的方案。参考:在 Windows 10 中安装 HTTP Toolkit 后对 Shopify CLI 3.x 的抓包流程]]>
https://www.shuijingwanwq.com/2023/11/24/8225/feed/ 0
在 PHP 7.4 中,判断变量值是否为 uri 格式的数据 https://www.shuijingwanwq.com/2023/11/13/8197/ https://www.shuijingwanwq.com/2023/11/13/8197/#respond Mon, 13 Nov 2023 02:38:48 +0000 https://www.shuijingwanwq.com/?p=8197 Post Views: 71 1、现在需要从一个一维数组中取出 uri 格式的数据。一维数组的打印结果,如图1
现在需要从一个一维数组中取出 uri 格式的数据。一维数组的打印结果

图1

<pre class="wp-block-syntaxhighlighter-code">

array(134) {
  [14]=>
  bool(false)
  [15]=>
  string(0) ""
  [16]=>
  string(6) "center"
  [17]=>
  string(7) "#ffffff"
  [18]=>
  string(95) "https://xxx.s3.us-east-2.amazonaws.com/image/736589fac73c7dfdbf61efadb49a95fb9af16efb.jpeg"
  [19]=>
  string(30) "<p>Image with text overlay</p>"
  [20]=>
  string(8) "Shop Now"
}


</pre>
2、基于 filter_var 代码实现如下,打印结果如下,不符合预期,其中存在:internal://policy_pages/29


foreach ($images->all() as $image) {
	var_dump($image, filter_var($image, FILTER_VALIDATE_URL));
	echo "\n";
}


<pre class="wp-block-syntaxhighlighter-code">

string(11) "collections"
bool(false)

bool(false)
bool(false)

string(6) "center"
bool(false)

string(4) "grid"
bool(false)

string(18) "this is collection"
bool(false)

string(19) "main-index-carousel"
bool(false)

string(5) "slide"
bool(false)

bool(false)
bool(false)

string(0) ""
bool(false)

string(6) "center"
bool(false)

string(7) "#ffffff"
bool(false)

string(95) "https://xxx.us-east-2.amazonaws.com/image/736589fac73c7dfdbf61efadb49a95fb9af16efb.jpeg"
string(95) "https://xxx.us-east-2.amazonaws.com/image/736589fac73c7dfdbf61efadb49a95fb9af16efb.jpeg"

string(30) "<p>Image with text overlay</p>"
bool(false)

string(8) "Shop Now"
bool(false)

string(26) "internal://policy_pages/29"
string(26) "internal://policy_pages/29"

</pre>
3、通过函数 parse_url 获取 scheme,判断是否为 http 或者 https。最后的过滤结果如下,符合预期。如图2
通过函数 parse_url 获取 scheme,判断是否为 http 或者 https。最后的过滤结果如下,符合预期

图2



$images = collect($data['sections'])->flatten()->reject(function ($image) {
	return !filter_var($image, FILTER_VALIDATE_URL);
})->reject(function ($image) {
	return !in_array(parse_url($image, PHP_URL_SCHEME), ['http', 'https']);
});
var_dump($images);




object(Illuminate\Support\Collection)#4918 (1) {
  ["items":protected]=>
  array(4) {
    [10]=>
    string(107) "https://cdn.xxx.com/image/2022/04/fa5d91ba9fd60ef1b050560895d2f15c02852f0d9669654de4c01c8b404af3f3.jpeg"
    [24]=>
    string(95) "https://xxx.us-east-2.amazonaws.com/image/736589fac73c7dfdbf61efadb49a95fb9af16efb.jpeg"
    [41]=>
    string(95) "https://xxx.us-east-2.amazonaws.com/image/7a204816a9625475044c8196bfb154b39aa3f12b.jpeg"
    [129]=>
    string(95) "https://xxx.us-east-2.amazonaws.com/image/736589fac73c7dfdbf61efadb49a95fb9af16efb.jpeg"
  }
}



]]>
https://www.shuijingwanwq.com/2023/11/13/8197/feed/ 0
dns_get_record(): DNS Query failed https://www.shuijingwanwq.com/2022/04/06/6246/ https://www.shuijingwanwq.com/2022/04/06/6246/#respond Wed, 06 Apr 2022 01:46:19 +0000 https://www.shuijingwanwq.com/?p=6246 Post Views: 103

1、报错:dns_get_record(): DNS Query failed。如图1

报错:dns_get_record(): DNS Query failed

图1


$records = dns_get_record($host, DNS_SRV);


2、打印 $host,其值为:https://object-wp.local/WP_ADMIN_USERNAME=admin

3、在浏览器中打开:https://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。但是确定 https://object-wp.local 是支持的。如图2

在浏览器中打开:https://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。但是确定 https://object-wp.local 是支持的

图2

4、当以 http:// 开头时,仍然报错:Warning: dns_get_record(): DNS Query failed。如图3

当以 http:// 开头时,仍然报错:Warning: dns_get_record(): DNS Query failed

图3

<?php
$host = 'http://object-wp.local/WP_ADMIN_USERNAME=admin';
$records = dns_get_record($host, DNS_SRV);
?>

5、在浏览器中打开:http://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。确定 https://object-wp.local 是不受支持的。WEB 服务器未监听 80 端口。如图4

在浏览器中打开:http://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。确定 https://object-wp.local 是不受支持的。WEB 服务器未监听 80 端口

图4

6、参考可以配置一个同时处理 HTTP 和 HTTPS 请求的服务器。https://nginx.org/en/docs/http/configuring_https_servers.html 。


server {
	listen 80;
	listen 443 ssl;
}


7、在浏览器中打开:http://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。但是确定 http://object-wp.local 已经是支持的。如图5

在浏览器中打开:http://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。但是确定 http://object-wp.local 已经是支持的。

图5

8、当以 http:// 开头时,仍然报错:Warning: dns_get_record(): DNS Query failed。

<?php
$host = 'http://object-wp.local/WP_ADMIN_USERNAME=admin';
$records = dns_get_record($host, DNS_SRV);
?>

9、当不以 http:// 开头时,仅剩下纯粹的域名,不再报错。结果为空数组。

<?php
$host = 'object-wp.local';
$records = dns_get_record($host, DNS_SRV);
print_r($records);
?>

Array
(
)



10、当不以 http:// 开头时,仅剩下纯粹的域名,且去掉参数:DNS_SRV。不再报错。结果不为空数组。如图6

由此可以确认,程序代码的处理逻辑上存在一定的问题。至少说明其是不支持 https:// 的相应配置的。

图6

<?php
$host = 'object-wp.local';
$records = dns_get_record($host);
print_r($records);
?>


Array
(
    [0] => Array
        (
            [host] => object-wp.local
            [class] => IN
            [ttl] => 604800
            [type] => A
            [ip] => 127.0.0.1
        )

)




11、由此可以确认,程序代码的处理逻辑上存在一定的问题。至少说明其是不支持 https:// 的相应配置的。

]]>
https://www.shuijingwanwq.com/2022/04/06/6246/feed/ 0
在 K8s 中 HTTP 响应 502,message:An invalid response was received from the upstream server https://www.shuijingwanwq.com/2021/10/08/5335/ https://www.shuijingwanwq.com/2021/10/08/5335/#respond Fri, 08 Oct 2021 08:58:41 +0000 https://www.shuijingwanwq.com/?p=5335 Post Views: 400 1、在 K8s 中 HTTP 响应 502 Bad Gateway,message:An invalid response was received from the upstream server。从上游服务器收到无效响应。502 Bad Gateway 错误具体表示服务器收到来自入站服务器的无效响应。kong/2.5.0。如图1
在 K8s 中 HTTP 响应 502 Bad Gateway,message:An invalid response was received from the upstream server。从上游服务器收到无效响应。502 Bad Gateway 错误具体表示服务器收到来自入站服务器的无效响应。kong/2.5.0。

图1

2、原因在于 GET 请求参数过多,参数量过大。参数总字数超过 1300 个。



{{host_info}}{{base_url}}/v{{module}}/task-group-channel-app-sources?filter[group_id]={{group_id}}&filter[channel_type_code][in][0]=vtt_douyin&filter[channel_type_code][in][1]=vtt_douyin_pro&filter[channel_type_code][in][2]=vtt_kuaishou&filter[channel_type_code][in][3]=vtt_kuaishou_pro&filter[channel_type_code][in][4]=vtt_baijia&filter[channel_type_code][in][5]=vtt_baijia_pro&filter[channel_type_code][in][6]=vtt_dayu&filter[channel_type_code][in][7]=vtt_dayu_pro&filter[channel_type_code][in][8]=vtt_qq&filter[channel_type_code][in][9]=vtt_yidian&filter[channel_type_code][in][10]=vtt_qutoutiao&filter[channel_type_code][in][11]=vtt_miaopai&filter[channel_type_code][in][12]=vtt_meipai&filter[channel_type_code][in][13]=vtt_rrtv&filter[channel_type_code][in][14]=vtt_sohutv&filter[channel_type_code][in][15]=vtt_sohu&filter[channel_type_code][in][16]=vtt_acfun&filter[channel_type_code][in][17]=vtt_yinyuetai&filter[channel_type_code][in][18]=vtt_neteasemusic&filter[channel_type_code][in][19]=vtt_cashtoutiao&filter[channel_type_code][in][20]=vtt_dianping&filter[channel_type_code][in][21]=vtt_weibo&filter[channel_type_code][in][22]=vtt_sina&filter[channel_type_code][in][23]=vtt_iqiyi&filter[channel_type_code][in][24]=vtt_toutiao_pro&filter[channel_type_code][in][25]=vtt_bilibili&filter[channel_type_code][in][26]=vtt_netease&filter[channel_type_code][in][27]=vtt_sogou&per-page=100&group_id={{group_id}}


filter[channel_type_code][in][0]:vtt_douyin
filter[channel_type_code][in][1]:vtt_douyin_pro
filter[channel_type_code][in][2]:vtt_kuaishou
filter[channel_type_code][in][3]:vtt_kuaishou_pro
filter[channel_type_code][in][4]:vtt_baijia
filter[channel_type_code][in][5]:vtt_baijia_pro
filter[channel_type_code][in][6]:vtt_dayu
filter[channel_type_code][in][7]:vtt_dayu_pro
filter[channel_type_code][in][8]:vtt_qq
filter[channel_type_code][in][9]:vtt_yidian
filter[channel_type_code][in][10]:vtt_qutoutiao
filter[channel_type_code][in][11]:vtt_miaopai
filter[channel_type_code][in][12]:vtt_meipai
filter[channel_type_code][in][13]:vtt_rrtv
filter[channel_type_code][in][14]:vtt_sohutv
filter[channel_type_code][in][15]:vtt_sohu
filter[channel_type_code][in][16]:vtt_acfun
filter[channel_type_code][in][17]:vtt_yinyuetai
filter[channel_type_code][in][18]:vtt_neteasemusic
filter[channel_type_code][in][19]:vtt_cashtoutiao
filter[channel_type_code][in][20]:vtt_dianping
filter[channel_type_code][in][21]:vtt_weibo
filter[channel_type_code][in][22]:vtt_sina
filter[channel_type_code][in][23]:vtt_iqiyi
filter[channel_type_code][in][24]:vtt_toutiao_pro
filter[channel_type_code][in][25]:vtt_bilibili
filter[channel_type_code][in][26]:vtt_netease
filter[channel_type_code][in][27]:vtt_sogou


3、总计 28 个请求参数,删减为 14 个。响应 200。如图2
总计 28 个请求参数,删减为 14 个。响应 200。

图2

4、查看容器中的 Nginx 日志,确定接口响应 502 时候,实际是响应 200 的。如图3
查看容器中的 Nginx 日志,确定接口响应 502 时候,实际是响应 200 的。

图3



{"environment-info":{"pod-id":"api-7cc8cc4c9c-hx89x","namespace":"ccp","pod-ip":"10.42.4.155","pod-hostip":"192.168.3.14"},"request":{"headers":{"referer":"-","host":"api.ccp","x-request-id":"156f0a80cc88c1ee0bb79b1f06d777f1","x-forwarded-for":"101.207.139.251, 10.42.0.231","user-agent":"PostmanRuntime/7.28.4"},"method":"GET","uri":"/v1/task-group-channel-app-sources?filter[group_id]=6c8b55e7387da4799772ddb389f06753&filter[channel_type_code][in][0]=vtt_douyin&filter[channel_type_code][in][1]=vtt_douyin_pro&filter[channel_type_code][in][2]=vtt_kuaishou&filter[channel_type_code][in][3]=vtt_kuaishou_pro&filter[channel_type_code][in][4]=vtt_baijia&filter[channel_type_code][in][5]=vtt_baijia_pro&filter[channel_type_code][in][6]=vtt_dayu&filter[channel_type_code][in][7]=vtt_dayu_pro&filter[channel_type_code][in][8]=vtt_qq&filter[channel_type_code][in][9]=vtt_yidian&filter[channel_type_code][in][10]=vtt_qutoutiao&filter[channel_type_code][in][11]=vtt_miaopai&filter[channel_type_code][in][12]=vtt_meipai&filter[channel_type_code][in][13]=vtt_rrtv&filter[channel_type_code][in][14]=vtt_sohutv&filter[channel_type_code][in][15]=vtt_sohu&filter[channel_type_code][in][16]=vtt_acfun&filter[channel_type_code][in][17]=vtt_yinyuetai&filter[channel_type_code][in][18]=vtt_neteasemusic&filter[channel_type_code][in][19]=vtt_cashtoutiao&filter[channel_type_code][in][20]=vtt_dianping&filter[channel_type_code][in][21]=vtt_weibo&filter[channel_type_code][in][22]=vtt_sina&filter[channel_type_code][in][23]=vtt_iqiyi&filter[channel_type_code][in][24]=vtt_toutiao_pro&filter[channel_type_code][in][25]=vtt_bilibili&filter[channel_type_code][in][26]=vtt_netease&filter[channel_type_code][in][27]=vtt_sogou&per-page=100&group_id=6c8b55e7387da4799772ddb389f06753","url":"http://api.ccp/v1/task-group-channel-app-sources?filter[group_id]=6c8b55e7387da4799772ddb389f06753&filter[channel_type_code][in][0]=vtt_douyin&filter[channel_type_code][in][1]=vtt_douyin_pro&filter[channel_type_code][in][2]=vtt_kuaishou&filter[channel_type_code][in][3]=vtt_kuaishou_pro&filter[channel_type_code][in][4]=vtt_baijia&filter[channel_type_code][in][5]=vtt_baijia_pro&filter[channel_type_code][in][6]=vtt_dayu&filter[channel_type_code][in][7]=vtt_dayu_pro&filter[channel_type_code][in][8]=vtt_qq&filter[channel_type_code][in][9]=vtt_yidian&filter[channel_type_code][in][10]=vtt_qutoutiao&filter[channel_type_code][in][11]=vtt_miaopai&filter[channel_type_code][in][12]=vtt_meipai&filter[channel_type_code][in][13]=vtt_rrtv&filter[channel_type_code][in][14]=vtt_sohutv&filter[channel_type_code][in][15]=vtt_sohu&filter[channel_type_code][in][16]=vtt_acfun&filter[channel_type_code][in][17]=vtt_yinyuetai&filter[channel_type_code][in][18]=vtt_neteasemusic&filter[channel_type_code][in][19]=vtt_cashtoutiao&filter[channel_type_code][in][20]=vtt_dianping&filter[channel_type_code][in][21]=vtt_weibo&filter[channel_type_code][in][22]=vtt_sina&filter[channel_type_code][in][23]=vtt_iqiyi&filter[channel_type_code][in][24]=vtt_toutiao_pro&filter[channel_type_code][in][25]=vtt_bilibili&filter[channel_type_code][in][26]=vtt_netease&filter[channel_type_code][in][27]=vtt_sogou&per-page=100&group_id=6c8b55e7387da4799772ddb389f06753","@timestamp":"2021-09-30T13:28:24+08:00","upstreamaddr":"127.0.0.1:9000","response":{"responsetime":"0.430","upstream-response-time":"0.430"},"size":"0","status":"200"},"module-name":"default_ccp_api"}


5、决定在另外一台容器中调用此接口,跳过 Kong 网关。报错:curl: (3) [globbing] error: bad range specification after pos 60。如图4
决定在另外一台容器中调用此接口,跳过 Kong 网关。报错:curl: (3) [globbing] error: bad range specification after pos 60。

图4



curl "http://api.ccp:82/v1/task-group-channel-app-sources?filter[group_id]=6c8b55e7387da4799772ddb389f06753&filter[channel_type_code][in][0]=vtt_douyin&filter[channel_type_code][in][1]=vtt_douyin_pro&filter[channel_type_code][in][2]=vtt_kuaishou&filter[channel_type_code][in][3]=vtt_kuaishou_pro&filter[channel_type_code][in][4]=vtt_baijia&filter[channel_type_code][in][5]=vtt_baijia_pro&filter[channel_type_code][in][6]=vtt_dayu&filter[channel_type_code][in][7]=vtt_dayu_pro&filter[channel_type_code][in][8]=vtt_qq&filter[channel_type_code][in][9]=vtt_yidian&filter[channel_type_code][in][10]=vtt_qutoutiao&filter[channel_type_code][in][11]=vtt_miaopai&filter[channel_type_code][in][12]=vtt_meipai&filter[channel_type_code][in][13]=vtt_rrtv&filter[channel_type_code][in][14]=vtt_sohutv&filter[channel_type_code][in][15]=vtt_sohu&filter[channel_type_code][in][16]=vtt_acfun&filter[channel_type_code][in][17]=vtt_yinyuetai&filter[channel_type_code][in][18]=vtt_neteasemusic&filter[channel_type_code][in][19]=vtt_cashtoutiao&filter[channel_type_code][in][20]=vtt_dianping&filter[channel_type_code][in][21]=vtt_weibo&filter[channel_type_code][in][22]=vtt_sina&filter[channel_type_code][in][23]=vtt_iqiyi&filter[channel_type_code][in][24]=vtt_toutiao_pro&filter[channel_type_code][in][25]=vtt_bilibili&filter[channel_type_code][in][26]=vtt_netease&filter[channel_type_code][in][27]=vtt_sogou&per-page=100&group_id=6c8b55e7387da4799772ddb389f06753"


6、将 [ 与 ] 前面添加 \,最终请求,响应成功。如图5
将 [ 与 ] 前面添加 \,最终请求,响应成功。

图5



[root@api-console-migrate-6fc4566467-qbfch /]# curl "http://api.ccp:82/v1/task-group-channel-app-sources?filter\[group_id\]=6c8b55e7387da4799772ddb389f06753&filter\[channel_type_code\]\[in\]\[0\]=vtt_douyin&filter\[channel_type_code\]\[in\]\[1\]=vtt_douyin_pro&filter\[channel_type_code\]\[in\]\[2\]=vtt_kuaishou&filter\[channel_type_code\]\[in\]\[3\]=vtt_kuaishou_pro&filter\[channel_type_code\]\[in\]\[4\]=vtt_baijia&filter\[channel_type_code\]\[in\]\[5\]=vtt_baijia_pro&filter\[channel_type_code\]\[in\]\[6\]=vtt_dayu&filter\[channel_type_code\]\[in\]\[7\]=vtt_dayu_pro&filter\[channel_type_code\]\[in\]\[8\]=vtt_qq&filter\[channel_type_code\]\[in\]\[9\]=vtt_yidian&filter\[channel_type_code\]\[in\]\[10\]=vtt_qutoutiao&filter\[channel_type_code\]\[in\]\[11\]=vtt_miaopai&filter\[channel_type_code\]\[in\]\[12\]=vtt_meipai&filter\[channel_type_code\]\[in\]\[13\]=vtt_rrtv&filter\[channel_type_code\]\[in\]\[14\]=vtt_sohutv&filter\[channel_type_code\]\[in\]\[15\]=vtt_sohu&filter\[channel_type_code\]\[in\]\[16\]=vtt_acfun&filter\[channel_type_code\]\[in\]\[17\]=vtt_yinyuetai&filter\[channel_type_code\]\[in\]\[18\]=vtt_neteasemusic&filter\[channel_type_code\]\[in\]\[19\]=vtt_cashtoutiao&filter\[channel_type_code\]\[in\]\[20\]=vtt_dianping&filter\[channel_type_code\]\[in\]\[21\]=vtt_weibo&filter\[channel_type_code\]\[in\]\[22\]=vtt_sina&filter\[channel_type_code\]\[in\]\[23\]=vtt_iqiyi&filter\[channel_type_code\]\[in\]\[24\]=vtt_toutiao_pro&filter\[channel_type_code\]\[in\]\[25\]=vtt_bilibili&filter\[channel_type_code\]\[in\]\[26\]=vtt_netease&filter\[channel_type_code\]\[in\]\[27\]=vtt_sogou&per-page=100&group_id=6c8b55e7387da4799772ddb389f06753"
{"code":10000,"message":"获取任务组的渠道的应用的来源的树形列表成功","data":{"items":[{"channel_code":"douyin","channel_name":"抖音","channel_type_code":"vtt_douyin_pro","channel_type_name":"视频兔兔的抖音PRO应用","channel_app_items":[{"group_id":"6c8b55e7387da4799772ddb389f06753","group_name":"省宣传部","uuid":"60e74fd01f6711ecaded82f5728d7d34","channel_code":"douyin","channel_type_code":"vtt_douyin_pro","name":"小燕子","avatar":"https://p3.douyinpic.com/aweme/1080x1080/31a3d00061fd573c41210.jpeg?from=4010531038","fans_count":0,"source":"scms","source_uuid":"b7498f517f48cab91408685674cabbac","source_product_id":"","source_user_token":"","permission":2,"refreshed_at":"0","status":1,"created_at":1632728941,"is_pub_able":1,"is_pub_message":"","channel_name":"抖音","channel_type_name":"视频兔兔的抖音PRO应用","channel_app_name":"小燕子"}]},{"channel_code":"kuaishou","channel_name":"快手","channel_type_code":"vtt_kuaishou_pro","channel_type_name":"视频兔兔的快手PRO应用","channel_app_items":[{"group_id":"6c8b55e7387da4799772ddb389f06753","group_name":"省宣传部","uuid":"4be7fa9e1f6711ecb02ca571b56d3826","channel_code":"kuaishou","channel_type_code":"vtt_kuaishou_pro","name":"User_1611141497927","avatar":"http://head-img.videototo.com/new_100009445_kuaishoupro_100025305","fans_count":0,"source":"scms","source_uuid":"b7498f517f48cab91408685674cabbac","source_product_id":"","source_user_token":"","permission":2,"refreshed_at":"0","status":1,"created_at":1632728906,"is_pub_able":1,"is_pub_message":"","channel_name":"快手","channel_type_name":"视频兔兔的快手PRO应用","channel_app_name":"User_1611141497927"}]},{"channel_code":"toutiao","channel_name":"头条号","channel_type_code":"vtt_toutiao_pro","channel_type_name":"视频兔兔的头条号PRO应用","channel_app_items":[{"group_id":"6c8b55e7387da4799772ddb389f06753","group_name":"省宣传部","uuid":"9af35d8a1f6311ecb6b115ad3c194da2","channel_code":"toutiao","channel_type_code":"vtt_toutiao_pro","name":"编辑器验证","avatar":"https://p3-passport.byteacctimg.com/img/user-avatar/2x_21863502d9f118168ad71160d7070b7b~300x300.image","fans_count":0,"source":"scms","source_uuid":"b7498f517f48cab91408685674cabbac","source_product_id":"","source_user_token":"","permission":2,"refreshed_at":"0","status":1,"created_at":1632727321,"is_pub_able":1,"is_pub_message":"","channel_name":"头条号","channel_type_name":"视频兔兔的头条号PRO应用","channel_app_name":"编辑器验证"}]},{"channel_code":"yidian","channel_name":"一点号","channel_type_code":"vtt_yidian","channel_type_name":"视频兔兔的一点号应用","channel_app_items":[{"group_id":"6c8b55e7387da4799772ddb389f06753","group_name":"省宣传部","uuid":"f0b531e41f4f11eca4df8bbcc22e30e6","channel_code":"yidian","channel_type_code":"vtt_yidian","name":"打工人1号","avatar":"http://head-img.videototo.com/Fpo_0phXgaUEMV5rxcB6LDw-bxb2","fans_count":0,"source":"scms","source_uuid":"b7498f517f48cab91408685674cabbac","source_product_id":"","source_user_token":"","permission":2,"refreshed_at":"0","status":1,"created_at":1632718878,"is_pub_able":1,"is_pub_message":"","channel_name":"一点号","channel_type_name":"视频兔兔的一点号应用","channel_app_name":"打工人1号"}]},{"channel_code":"bilibili","channel_name":"哔哩哔哩","channel_type_code":"vtt_bilibili","channel_type_name":"视频兔兔的哔哩哔哩应用","channel_app_items":[{"group_id":"6c8b55e7387da4799772ddb389f06753","group_name":"省宣传部","uuid":"202cf6cc1f4711ecacc51ebe835c0f9a","channel_code":"bilibili","channel_type_code":"vtt_bilibili","name":"小燕子_bili","avatar":"http://head-img.videototo.com/FgMEsVrcqD5DidOIkiGgZNHQAbYf","fans_count":0,"source":"scms","source_uuid":"b7498f517f48cab91408685674cabbac","source_product_id":"","source_user_token":"","permission":2,"refreshed_at":"0","status":1,"created_at":1632715089,"is_pub_able":1,"is_pub_message":"","channel_name":"哔哩哔哩","channel_type_name":"视频兔兔的哔哩哔哩应用","channel_app_name":"小燕子_bili"}]},{"channel_code":"dayu","channel_name":"大鱼号","channel_type_code":"vtt_dayu_pro","channel_type_name":"视频兔兔的大鱼号PRO应用","channel_app_items":[{"group_id":"6c8b55e7387da4799772ddb389f06753","group_name":"省宣传部","uuid":"5e7fd6be1f4311ec92a5417c9aac2b41","channel_code":"dayu","channel_type_code":"vtt_dayu_pro","name":"快乐萌萌","avatar":"http://head-img.videototo.com/Fq5BSc10S9rvn4doFQ--JU8hAeZL","fans_count":0,"source":"scms","source_uuid":"b7498f517f48cab91408685674cabbac","source_product_id":"","source_user_token":"","permission":2,"refreshed_at":"0","status":1,"created_at":1632713490,"is_pub_able":1,"is_pub_message":"","channel_name":"大鱼号","channel_type_name":"视频兔兔的大鱼号PRO应用","channel_app_name":"快乐萌萌"}]}],"_links":{"self":{"href":"http://api.ccp:82/v1/task-group-channel-app-sources?filter%5Bgroup_id%5D=6c8b55e7387da4799772ddb389f06753&filter%5Bchannel_type_code%5D%5Bin%5D%5B0%5D=vtt_douyin&filter%5Bchannel_type_code%5D%5Bin%5D%5B1%5D=vtt_douyin_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B2%5D=vtt_kuaishou&filter%5Bchannel_type_code%5D%5Bin%5D%5B3%5D=vtt_kuaishou_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B4%5D=vtt_baijia&filter%5Bchannel_type_code%5D%5Bin%5D%5B5%5D=vtt_baijia_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B6%5D=vtt_dayu&filter%5Bchannel_type_code%5D%5Bin%5D%5B7%5D=vtt_dayu_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B8%5D=vtt_qq&filter%5Bchannel_type_code%5D%5Bin%5D%5B9%5D=vtt_yidian&filter%5Bchannel_type_code%5D%5Bin%5D%5B10%5D=vtt_qutoutiao&filter%5Bchannel_type_code%5D%5Bin%5D%5B11%5D=vtt_miaopai&filter%5Bchannel_type_code%5D%5Bin%5D%5B12%5D=vtt_meipai&filter%5Bchannel_type_code%5D%5Bin%5D%5B13%5D=vtt_rrtv&filter%5Bchannel_type_code%5D%5Bin%5D%5B14%5D=vtt_sohutv&filter%5Bchannel_type_code%5D%5Bin%5D%5B15%5D=vtt_sohu&filter%5Bchannel_type_code%5D%5Bin%5D%5B16%5D=vtt_acfun&filter%5Bchannel_type_code%5D%5Bin%5D%5B17%5D=vtt_yinyuetai&filter%5Bchannel_type_code%5D%5Bin%5D%5B18%5D=vtt_neteasemusic&filter%5Bchannel_type_code%5D%5Bin%5D%5B19%5D=vtt_cashtoutiao&filter%5Bchannel_type_code%5D%5Bin%5D%5B20%5D=vtt_dianping&filter%5Bchannel_type_code%5D%5Bin%5D%5B21%5D=vtt_weibo&filter%5Bchannel_type_code%5D%5Bin%5D%5B22%5D=vtt_sina&filter%5Bchannel_type_code%5D%5Bin%5D%5B23%5D=vtt_iqiyi&filter%5Bchannel_type_code%5D%5Bin%5D%5B24%5D=vtt_toutiao_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B25%5D=vtt_bilibili&filter%5Bchannel_type_code%5D%5Bin%5D%5B26%5D=vtt_netease&filter%5Bchannel_type_code%5D%5Bin%5D%5B27%5D=vtt_sogou&per-page=6&group_id=6c8b55e7387da4799772ddb389f06753&page=1"},"first":{"href":"http://api.ccp:82/v1/task-group-channel-app-sources?filter%5Bgroup_id%5D=6c8b55e7387da4799772ddb389f06753&filter%5Bchannel_type_code%5D%5Bin%5D%5B0%5D=vtt_douyin&filter%5Bchannel_type_code%5D%5Bin%5D%5B1%5D=vtt_douyin_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B2%5D=vtt_kuaishou&filter%5Bchannel_type_code%5D%5Bin%5D%5B3%5D=vtt_kuaishou_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B4%5D=vtt_baijia&filter%5Bchannel_type_code%5D%5Bin%5D%5B5%5D=vtt_baijia_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B6%5D=vtt_dayu&filter%5Bchannel_type_code%5D%5Bin%5D%5B7%5D=vtt_dayu_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B8%5D=vtt_qq&filter%5Bchannel_type_code%5D%5Bin%5D%5B9%5D=vtt_yidian&filter%5Bchannel_type_code%5D%5Bin%5D%5B10%5D=vtt_qutoutiao&filter%5Bchannel_type_code%5D%5Bin%5D%5B11%5D=vtt_miaopai&filter%5Bchannel_type_code%5D%5Bin%5D%5B12%5D=vtt_meipai&filter%5Bchannel_type_code%5D%5Bin%5D%5B13%5D=vtt_rrtv&filter%5Bchannel_type_code%5D%5Bin%5D%5B14%5D=vtt_sohutv&filter%5Bchannel_type_code%5D%5Bin%5D%5B15%5D=vtt_sohu&filter%5Bchannel_type_code%5D%5Bin%5D%5B16%5D=vtt_acfun&filter%5Bchannel_type_code%5D%5Bin%5D%5B17%5D=vtt_yinyuetai&filter%5Bchannel_type_code%5D%5Bin%5D%5B18%5D=vtt_neteasemusic&filter%5Bchannel_type_code%5D%5Bin%5D%5B19%5D=vtt_cashtoutiao&filter%5Bchannel_type_code%5D%5Bin%5D%5B20%5D=vtt_dianping&filter%5Bchannel_type_code%5D%5Bin%5D%5B21%5D=vtt_weibo&filter%5Bchannel_type_code%5D%5Bin%5D%5B22%5D=vtt_sina&filter%5Bchannel_type_code%5D%5Bin%5D%5B23%5D=vtt_iqiyi&filter%5Bchannel_type_code%5D%5Bin%5D%5B24%5D=vtt_toutiao_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B25%5D=vtt_bilibili&filter%5Bchannel_type_code%5D%5Bin%5D%5B26%5D=vtt_netease&filter%5Bchannel_type_code%5D%5Bin%5D%5B27%5D=vtt_sogou&per-page=6&group_id=6c8b55e7387da4799772ddb389f06753&page=1"},"last":{"href":"http://api.ccp:82/v1/task-group-channel-app-sources?filter%5Bgroup_id%5D=6c8b55e7387da4799772ddb389f06753&filter%5Bchannel_type_code%5D%5Bin%5D%5B0%5D=vtt_douyin&filter%5Bchannel_type_code%5D%5Bin%5D%5B1%5D=vtt_douyin_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B2%5D=vtt_kuaishou&filter%5Bchannel_type_code%5D%5Bin%5D%5B3%5D=vtt_kuaishou_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B4%5D=vtt_baijia&filter%5Bchannel_type_code%5D%5Bin%5D%5B5%5D=vtt_baijia_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B6%5D=vtt_dayu&filter%5Bchannel_type_code%5D%5Bin%5D%5B7%5D=vtt_dayu_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B8%5D=vtt_qq&filter%5Bchannel_type_code%5D%5Bin%5D%5B9%5D=vtt_yidian&filter%5Bchannel_type_code%5D%5Bin%5D%5B10%5D=vtt_qutoutiao&filter%5Bchannel_type_code%5D%5Bin%5D%5B11%5D=vtt_miaopai&filter%5Bchannel_type_code%5D%5Bin%5D%5B12%5D=vtt_meipai&filter%5Bchannel_type_code%5D%5Bin%5D%5B13%5D=vtt_rrtv&filter%5Bchannel_type_code%5D%5Bin%5D%5B14%5D=vtt_sohutv&filter%5Bchannel_type_code%5D%5Bin%5D%5B15%5D=vtt_sohu&filter%5Bchannel_type_code%5D%5Bin%5D%5B16%5D=vtt_acfun&filter%5Bchannel_type_code%5D%5Bin%5D%5B17%5D=vtt_yinyuetai&filter%5Bchannel_type_code%5D%5Bin%5D%5B18%5D=vtt_neteasemusic&filter%5Bchannel_type_code%5D%5Bin%5D%5B19%5D=vtt_cashtoutiao&filter%5Bchannel_type_code%5D%5Bin%5D%5B20%5D=vtt_dianping&filter%5Bchannel_type_code%5D%5Bin%5D%5B21%5D=vtt_weibo&filter%5Bchannel_type_code%5D%5Bin%5D%5B22%5D=vtt_sina&filter%5Bchannel_type_code%5D%5Bin%5D%5B23%5D=vtt_iqiyi&filter%5Bchannel_type_code%5D%5Bin%5D%5B24%5D=vtt_toutiao_pro&filter%5Bchannel_type_code%5D%5Bin%5D%5B25%5D=vtt_bilibili&filter%5Bchannel_type_code%5D%5Bin%5D%5B26%5D=vtt_netease&filter%5Bchannel_type_code%5D%5Bin%5D%5B27%5D=vtt_sogou&per-page=6&group_id=6c8b55e7387da4799772ddb389f06753&page=1"}},"_meta":{"totalCount":6,"pageCount":1,"currentPage":1,"perPage":6}}}[root@api-console-migrate-6fc4566467-qbfch /]# 


7、一直减少至 18 个参数后,就能够正常响应 200。总计为 918 个字符数。虽然官方 RFC 2616 没有指定限制,但许多安全协议和建议都规定服务器上的 maxQueryStrings 应设置为最大字符数限制 1024。而整个 URL,包括查询字符串,应设置为最大 2048 。


{{host_info}}{{base_url}}/v{{module}}/task-group-channel-app-sources?filter[group_id]={{group_id}}&filter[channel_type_code][in][0]=vtt_douyin&filter[channel_type_code][in][1]=vtt_douyin_pro&filter[channel_type_code][in][2]=vtt_kuaishou&filter[channel_type_code][in][3]=vtt_kuaishou_pro&filter[channel_type_code][in][4]=vtt_baijia&filter[channel_type_code][in][5]=vtt_baijia_pro&filter[channel_type_code][in][6]=vtt_dayu&filter[channel_type_code][in][7]=vtt_dayu_pro&filter[channel_type_code][in][8]=vtt_qq&filter[channel_type_code][in][9]=vtt_yidian&filter[channel_type_code][in][10]=vtt_qutoutiao&filter[channel_type_code][in][11]=vtt_miaopai&filter[channel_type_code][in][12]=vtt_meipai&filter[channel_type_code][in][13]=vtt_rrtv&filter[channel_type_code][in][14]=vtt_sohutv&filter[channel_type_code][in][15]=vtt_sohu&filter[channel_type_code][in][16]=vtt_acfun&filter[channel_type_code][in][17]=vtt_yinyuetai&per-page=100&group_id={{group_id}}


8、查看 Kong 的 tcp log。upstream sent too big header while reading response header from upstream。如图6
查看 Kong 的 tcp log。upstream sent too big header while reading response header from upstream。

图6



2021/09/30 09:10:12 [error] 65#0: *8025344 upstream sent too big header while reading response header from upstream, client: 10.42.0.231, server: kong, request: "GET /ccpapi/v1/task-group-channel-app-sources?filter[group_id]=6c8b55e7387da4799772ddb389f06753&filter[channel_type_code][in][0]=vtt_douyin&filter[channel_type_code][in][1]=vtt_douyin_pro&filter[channel_type_code][in][2]=vtt_kuaishou&filter[channel_type_code][in][3]=vtt_kuaishou_pro&filter[channel_type_code][in][4]=vtt_baijia&filter[channel_type_code][in][5]=vtt_baijia_pro&filter[channel_type_code][in][6]=vtt_dayu&filter[channel_type_code][in][7]=vtt_dayu_pro&filter[channel_type_code][in][8]=vtt_qq&filter[channel_type_code][in][9]=vtt_yidian&filter[channel_type_code][in][10]=vtt_qutoutiao&filter[channel_type_code][in][11]=vtt_miaopai&filter[channel_type_code][in][12]=vtt_meipai&filter[channel_type_code][in][13]=vtt_rrtv&filter[channel_type_code][in][14]=vtt_sohutv&filter[channel_type_code][in][15]=vtt_sohu&filter[channel_type_code][in][16]=vtt_acfun&filter[channel_type_code][in][17]=vtt_yinyuetai&filter[channel_type_code][in][18]=vtt_neteasemusic&per-page=100&group_id=6c8b55e7387da4799772ddb389f06753 HTTP/1.1", upstream: "http://10.103.175.193:82/v1/task-group-channel-app-sources?filter[group_id]=6c8b55e7387da4799772ddb389f06753&filter[channel_type_code][in][0]=vtt_douyin&filter[channel_type_code][in][1]=vtt_douyin_pro&filter[channel_type_code][in][2]=vtt_kuaishou&filter[channel_type_code][in][3]=vtt_kuaishou_pro&filter[channel_type_code][in][4]=vtt_baijia&filter[channel_type_code][in][5]=vtt_baijia_pro&filter[channel_type_code][in][6]=vtt_dayu&filter[channel_type_code][in][7]=vtt_dayu_pro&filter[channel_type_code][in][8]=vtt_qq&filter[channel_type_code][in][9]=vtt_yidian&filter[channel_type_code][in][10]=vtt_qutoutiao&filter[channel_type_code][in][11]=vtt_miaopai&filter[channel_type_code][in][12]=vtt_meipai&filter[channel_type_code][in][13]=vtt_rrtv&filter[channel_type_code][in][14]=vtt_sohutv&filter[channel_type_code][in][ 
15]=vtt_sohu&filter[channel_type_code][in][16]=vtt_acfun&filter[channel_type_code][in][17]=vtt_yinyuetai&filter[channel_type_code][in][18]=vtt_neteasemusic&per-page=100&group_id=6c8b55e7387da4799772ddb389f06753", host: "api.webtest.chinamcloud.cn" 
10.42.0.231 - - [30/Sep/2021:09:10:12 +0000] "GET /ccpapi/v1/task-group-channel-app-sources?filter[group_id]=6c8b55e7387da4799772ddb389f06753&filter[channel_type_code][in][0]=vtt_douyin&filter[channel_type_code][in][1]=vtt_douyin_pro&filter[channel_type_code][in][2]=vtt_kuaishou&filter[channel_type_code][in][3]=vtt_kuaishou_pro&filter[channel_type_code][in][4]=vtt_baijia&filter[channel_type_code][in][5]=vtt_baijia_pro&filter[channel_type_code][in][6]=vtt_dayu&filter[channel_type_code][in][7]=vtt_dayu_pro&filter[channel_type_code][in][8]=vtt_qq&filter[channel_type_code][in][9]=vtt_yidian&filter[channel_type_code][in][10]=vtt_qutoutiao&filter[channel_type_code][in][11]=vtt_miaopai&filter[channel_type_code][in][12]=vtt_meipai&filter[channel_type_code][in][13]=vtt_rrtv&filter[channel_type_code][in][14]=vtt_sohutv&filter[channel_type_code][in][15]=vtt_sohu&filter[channel_type_code][in][16]=vtt_acfun&filter[channel_type_code][in][17]=vtt_yinyuetai&filter[channel_type_code][in][18]=vtt_neteasemusic&per-page=100&group_id=6c8b55e7387da4799772ddb389f06753 HTTP/1.1" 502 75 "-" "PostmanRuntime/7.28.4" 


9、在 kong 容器中添加环境变量。KONG_NGINX_PROXY_PROXY_BUFFER_SIZE、KONG_NGINX_PROXY_PROXY_BUFFERS。如图7
在 kong 容器中添加环境变量。KONG_NGINX_PROXY_PROXY_BUFFER_SIZE、KONG_NGINX_PROXY_PROXY_BUFFERS。

图7



KONG_NGINX_PROXY_PROXY_BUFFER_SIZE=160k
KONG_NGINX_PROXY_PROXY_BUFFERS=64 160k


10、再次请求,仍然响应 502,只不过响应体发生了变化,响应 HTML 。如图8
再次请求,仍然响应 502,只不过响应体发生了变化,响应 HTML 。

图8

<pre class="wp-block-syntaxhighlighter-code">

<html>

<head>
	<title>502 Bad Gateway</title>
</head>

<body>
	<center>
		<h1>502 Bad Gateway</h1>
	</center>
	<hr>
	<center>nginx/1.17.10</center>
</body>

</html>

</pre>
11、查看 Kong 的 tcp log。未再报错。如图9
查看 Kong 的 tcp log。未再报错。

图9



10.42.0.231 - - [30/Sep/2021:10:34:36 +0000] "GET /ccpapi/v1/task-group-channel-app-sources?filter[group_id]=6c8b55e7387da4799772ddb389f06753&filter[channel_type_code][in][0]=vtt_douyin&filter[channel_type_code][in][1]=vtt_douyin_pro&filter[channel_type_code][in][2]=vtt_kuaishou&filter[channel_type_code][in][3]=vtt_kuaishou_pro&filter[channel_type_code][in][4]=vtt_baijia&filter[channel_type_code][in][5]=vtt_baijia_pro&filter[channel_type_code][in][6]=vtt_dayu&filter[channel_type_code][in][7]=vtt_dayu_pro&filter[channel_type_code][in][8]=vtt_qq&filter[channel_type_code][in][9]=vtt_yidian&filter[channel_type_code][in][10]=vtt_qutoutiao&filter[channel_type_code][in][11]=vtt_miaopai&filter[channel_type_code][in][12]=vtt_meipai&filter[channel_type_code][in][13]=vtt_rrtv&filter[channel_type_code][in][14]=vtt_sohutv&filter[channel_type_code][in][15]=vtt_sohu&filter[channel_type_code][in][16]=vtt_acfun&filter[channel_type_code][in][17]=vtt_yinyuetai&filter[channel_type_code][in][18]=vtt_neteasemusic&per-page=100&group_id=6c8b55e7387da4799772ddb389f06753 HTTP/1.1" 200 0 "-" "PostmanRuntime/7.28.4" 


12、参考网址:https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#proxy-buffers-number 。在 Rancher 中,查找到 kong 容器所对应的负载均衡,编辑 YAML 文件。添加 2 行 nginx.ingress 相关配置项。如图10
参考网址:https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#proxy-buffers-number 。在 Rancher 中,查找到 kong 容器所对应的负载均衡,编辑 YAML 文件。添加 2 行 nginx.ingress 相关配置项。

图10



    nginx.ingress.kubernetes.io/proxy-buffer-size: 160k
    nginx.ingress.kubernetes.io/proxy-buffers-number: "64"


13、再次请求,响应 200,符合预期。如图11
再次请求,响应 200,符合预期。

图11

]]>
https://www.shuijingwanwq.com/2021/10/08/5335/feed/ 0
在 Windows 10 的本地环境配置 HTTPS(https://localhost),基于 mkcert https://www.shuijingwanwq.com/2021/09/03/5222/ https://www.shuijingwanwq.com/2021/09/03/5222/#respond Fri, 03 Sep 2021 03:12:06 +0000 https://www.shuijingwanwq.com/?p=5222 Post Views: 474 1、现在本地环境网址:http://morefun.dev.xxx.cn/ 希望获取到开发环境网址:https://.xxx.cn 下的 Cookie 数据,发现无法获取。原因在于 http 与 https 的差异。 2、在本地环境配置网址:https://morefun.dev.xxx.cn/ 。 3、参考网址:https://web.dev/how-to-use-local-https/ 。如何使用HTTPS进行本地开发。有时,您需要使用 HTTPS 运行本地开发站点。安全快速地执行此操作的工具和提示。如图1
参考网址:https://web.dev/how-to-use-local-https/ 。如何使用HTTPS进行本地开发。有时,您需要使用 HTTPS 运行本地开发站点。安全快速地执行此操作的工具和提示。

图1

4、在特殊情况下才需要在本地使用 HTTPS,例如自定义主机名或跨浏览器的安全 cookie。现在的情况就是跨浏览器的安全 cookie。如果您的生产网站使用 HTTPS,您希望本地开发网站的行为类似于 HTTPS 网站。 5、使用 mkcert 使用 HTTPS 在本地运行您的站点(推荐)。如果您使用 HTTPS 在浏览器中打开本地运行的站点,您的浏览器将检查本地开发服务器的证书。在看到证书已由 mkcert 生成的证书颁发机构签名后,浏览器会检查它是否已注册为受信任的证书颁发机构。mkcert 被列为受信任的颁发机构,因此您的浏览器信任该证书并创建 HTTPS 连接。 6、mkcert 是一个简单的工具,用于制作本地信任的开发证书。 它不需要配置。参考网址:https://github.com/FiloSottile/mkcert 。在 Windows 上,使用预构建的二进制文件。下载:mkcert-v1.4.3-windows-amd64.exe 至目录:E:/wwwroot。如图2
mkcert 是一个简单的工具,用于制作本地信任的开发证书。 它不需要配置。参考网址:https://github.com/FiloSottile/mkcert 。在 Windows 上,使用预构建的二进制文件。下载:mkcert-v1.4.3-windows-amd64.exe 至目录:E:/wwwroot。

图2

7、以管理员身份运行 PowerShell,进入目录:E:/wwwroot,将 mkcert 添加到本地根 CA。在您的终端中,运行以下命令:,点击 是,本地 CA 现已安装在系统信任库中! ⚡注意:Firefox 支持在您的平台上不可用。如图3
以管理员身份运行 PowerShell,进入目录:E:/wwwroot,将 mkcert 添加到本地根 CA。在您的终端中,运行以下命令:,点击 是,本地 CA 现已安装在系统信任库中! ⚡注意:Firefox 支持在您的平台上不可用。

图3



PS E:\wwwroot> ./mkcert-v1.4.3-windows-amd64.exe install
Note: the local CA is not installed in the system trust store.
Run "mkcert -install" for certificates to be trusted automatically ⚠️

Created a new certificate valid for the following names 📜
 - "install"

The certificate is at "./install.pem" and the key at "./install-key.pem" ✅

It will expire on 2 December 2023 �
PS E:\wwwroot> ./mkcert-v1.4.3-windows-amd64.exe -install
The local CA is now installed in the system trust store! ⚡️
Note: Firefox support is not available on your platform. ℹ️

PS E:\wwwroot>�


8、为您的站点生成一个由 mkcert 签名的证书。导航到站点(https://localhost)的根目录。如图4
为您的站点生成一个由 mkcert 签名的证书。导航到站点(https://localhost)的根目录。

图4



PS E:\wwwroot> ./mkcert-v1.4.3-windows-amd64.exe localhost

Created a new certificate valid for the following names 📜
 - "localhost"

The certificate is at "./localhost.pem" and the key at "./localhost-key.pem" ✅

It will expire on 2 December 2023 🗓

PS E:\wwwroot>


9、在本地环境的 Nginx 配置文件中添加对于证书的支持。剪切文件至:C:/nginx-1.10.1/conf/localhost.pem、C:/nginx-1.10.1/conf/localhost-key.pem。编辑 C:/nginx-1.10.1/conf/nginx.conf。添加以 ssl 开头的 3 行。监听端口修改为 443。如图5
在本地环境的 Nginx 配置文件中添加对于证书的支持。剪切文件至:C:/nginx-1.10.1/conf/localhost.pem、C:/nginx-1.10.1/conf/localhost-key.pem。编辑 C:/nginx-1.10.1/conf/nginx.conf。添加以 ssl 开头的 3 行。监听端口修改为 443。

图5



    server {
        listen 443;
        server_name  localhost;

		client_max_body_size 200m;
		client_body_buffer_size 1024k;

		fastcgi_read_timeout 180s;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

		ssl on;
		ssl_certificate localhost.pem;
		ssl_certificate_key localhost-key.pem;

        location / {
            root   E:/wwwroot;
            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
	    fastcgi_split_path_info ^(.+\.php)(/.+)$;
            root           E:/wwwroot;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


10、在 Chrome 浏览器中打开网址:https://localhost/phpinfo.php ,访问成功,符合预期。如图6
在 Chrome 浏览器中打开网址:https://localhost/phpinfo.php ,访问成功,符合预期。

图6

11、以管理员身份运行 PowerShell,进入目录:E:/wwwroot,为您的站点(https://morefun.dev.xxx.cn)生成一个由 mkcert 签名的证书。


PS E:\wwwroot> ./mkcert-v1.4.3-windows-amd64.exe morefun.dev.xxx.cn

Created a new certificate valid for the following names 📜
 - "morefun.dev.xxx.cn"

The certificate is at "./morefun.dev.xxx.cn.pem" and the key at "./morefun.dev.xxx.cn-key.pem" ✅

It will expire on 2 December 2023 🗓



12、参考以上的步骤,复制证书文件,编辑 Nginx 文件。打开网址:https://morefun.dev.xxx.cn/ ,在 Cookies 中,已经能够获取到开发环境网址:https://.xxx.cn 下的 Cookie 数据 。如图7
参考以上的步骤,复制证书文件,编辑 Nginx 文件。打开网址:https://morefun.dev.xxx.cn/ ,在 Cookies 中,已经能够获取到开发环境网址:https://.xxx.cn 下的 Cookie 数据 。

图7

]]>
https://www.shuijingwanwq.com/2021/09/03/5222/feed/ 0
在 PHP 中基于 HTTP 协议检测文件的大小(即不下载文件的情况下,获取远程文件的大小),使用 URL 函数 get_headers — 取得服务器响应一个 HTTP 请求所发送的所有标头 https://www.shuijingwanwq.com/2021/08/11/5166/ https://www.shuijingwanwq.com/2021/08/11/5166/#respond Wed, 11 Aug 2021 03:37:24 +0000 https://www.shuijingwanwq.com/?p=5166 Post Views: 101

1、参考网址:https://www.shuijingwanwq.com/2021/08/10/5155/ 。在 PHP 中基于 HTTP 协议检测文件的大小(即不下载文件的情况下,获取远程文件的大小),之前的实现,使用文件系统函数 fopen — 打开文件或者 URL。如果文件的网址需要 301 跳转,则不能够获取到文件的真实大小。如图1

参考网址:https://www.shuijingwanwq.com/2021/08/10/5155/ 。在 PHP 中基于 HTTP 协议检测文件的大小(即不下载文件的情况下,获取远程文件的大小),之前的实现,使用文件系统函数 fopen — 打开文件或者 URL。如果文件的网址需要 301 跳转,则不能够获取到文件的真实大小。

图1

<?php
function remote_filesize($url) {
    static $regex = '/^Content-Length: *+\K\d++$/im';
    // 将 $url 指定的名字资源绑定到一个流上,只读方式打开,将文件指针指向文件头
    if (!$fp = @fopen($url, 'rb')) {
        return 0;
    }
    // 执行 fopen() 时可以使用变量 $http_response_header。其中包含响应标头的数组。
    if (
        isset($http_response_header) &&
        preg_match($regex, implode("\n", $http_response_header), $matches)
    ) {
        print_r($http_response_header);
        return (int)$matches[0];
    }
    return 0;
}
 
$startTime = microtime(true);
$url = 'https://www.shuijingwanwq.com/wp-content/uploads/2021/07/ChinaJoy 2015 上海 梦幻西游.mp4';
echo remote_filesize($url) . "\n";
$endTime = microtime(true);
echo '耗费时间:' . ($endTime - $startTime) . '秒';
?>


Array
(
    [0] => HTTP/1.1 301 Moved Permanently
    [1] => Server: nginx
    [2] => Date: Tue, 10 Aug 2021 05:16:59 GMT
    [3] => Content-Type: text/html
    [4] => Content-Length: 162
    [5] => Connection: close
    [6] => Location: https://www.shuijingwanwq.com/wp-content/uploads/2021/07/ChinaJoy 2015 上海 梦幻西游.mp4
    [7] => Strict-Transport-Security: max-age=15768000
    [8] => HTTP/1.1 200 OK
    [9] => Server: nginx
    [10] => Date: Tue, 10 Aug 2021 05:17:00 GMT
    [11] => Content-Type: video/mp4
    [12] => Content-Length: 123596884
    [13] => Last-Modified: Tue, 04 Dec 2018 06:27:23 GMT
    [14] => Connection: close
    [15] => ETag: "5c061e4b-75df054"
    [16] => Expires: Thu, 09 Sep 2021 05:17:00 GMT
    [17] => Cache-Control: max-age=2592000
    [18] => Strict-Transport-Security: max-age=15768000
    [19] => Accept-Ranges: bytes
)
162
耗费时间:0.34205508232117秒


2、参考网址:https://www.php.net/manual/zh/function.get-headers 。决定使用 URL 函数 get_headers() 返回一个数组,包含有服务器响应一个 HTTP 请求所发送的标头。

3、新的实现方案,其代码更为简洁,且耗费时间更短。不过如果文件的网址需要 301 跳转,则不能够获取到文件的真实大小的问题仍然存在。如图2

新的实现方案,其代码更为简洁,且耗费时间更短。不过如果文件的网址需要 301 跳转,则不能够获取到文件的真实大小的问题仍然存在。

图2

<?php
function remote_filesize($url) {
    // 返回一个数组,包含有服务器响应一个 HTTP 请求所发送的标头。
    $headers = get_headers($url, 1);
    if ($headers !== false && isset($headers['Content-Length'][0])) {
        print_r($headers);
        return $headers['Content-Length'][0];
    }
    return 0;
}
 
$startTime = microtime(true);
$url = 'https://www.shuijingwanwq.com/wp-content/uploads/2021/07/ChinaJoy 2015 上海 梦幻西游.mp4';
echo remote_filesize($url) . "\n";
$endTime = microtime(true);
echo '耗费时间:' . ($endTime - $startTime) . '秒';
?>


Array
(
    [0] => HTTP/1.1 301 Moved Permanently
    [Server] => Array
        (
            [0] => nginx
            [1] => nginx
        )

    [Date] => Array
        (
            [0] => Tue, 10 Aug 2021 05:48:21 GMT
            [1] => Tue, 10 Aug 2021 05:48:21 GMT
        )

    [Content-Type] => Array
        (
            [0] => text/html
            [1] => video/mp4
        )

    [Content-Length] => Array
        (
            [0] => 162
            [1] => 123596884
        )

    [Connection] => Array
        (
            [0] => close
            [1] => close
        )

    [Location] => https://www.shuijingwanwq.com/wp-content/uploads/2021/07/ChinaJoy 2015 上海 梦幻西游.mp4
    [Strict-Transport-Security] => Array
        (
            [0] => max-age=15768000
            [1] => max-age=15768000
        )

    [1] => HTTP/1.1 200 OK
    [Last-Modified] => Tue, 04 Dec 2018 06:27:23 GMT
    [ETag] => "5c061e4b-75df054"
    [Expires] => Thu, 09 Sep 2021 05:48:21 GMT
    [Cache-Control] => max-age=2592000
    [Accept-Ranges] => bytes
)
162
耗费时间:0.27841401100159秒


4、新的实现方案,如果文件的网址不需要 301 跳转,则不存在:Location 。如图3

新的实现方案,如果文件的网址不需要 301 跳转,则不存在:Location

图3



Array
(
    [0] => HTTP/1.1 200 OK
    [Server] => nginx
    [Date] => Tue, 10 Aug 2021 05:49:20 GMT
    [Content-Type] => video/mp4
    [Content-Length] => 123596884
    [Last-Modified] => Tue, 04 Dec 2018 06:27:23 GMT
    [Connection] => close
    [ETag] => "5c061e4b-75df054"
    [Expires] => Thu, 09 Sep 2021 05:49:20 GMT
    [Cache-Control] => max-age=2592000
    [Strict-Transport-Security] => max-age=15768000
    [Accept-Ranges] => bytes
)
1
耗费时间:0.17363715171814秒


5、如果文件的网址需要 301 跳转,则继续请求 301 跳转的网址,以获取文件的大小。代码实现如下。最终获取到跳转后的文件的真实大小。如图4

如果文件的网址需要 301 跳转,则继续请求 301 跳转的网址,以获取文件的大小。代码实现如下。最终获取到跳转后的文件的真实大小。

图4

<?php
function remote_filesize($url) {
    echo 0 . "\n";
    // 返回一个数组,包含有服务器响应一个 HTTP 请求所发送的标头。
    $filesize = 0;
    $headers = get_headers($url, 1);
 
    if ($headers !== false) {
        echo 1 . "\n";
        if (!isset($headers['Location']) && isset($headers['Content-Length'])) {
            echo 2 . "\n";
            $filesize = $headers['Content-Length'];
        }
        if (isset($headers['Location'])) {
            echo 3 . "\n";
            return remote_filesize($headers['Location']);
        }
    }
 
    return $filesize;
}
 
$startTime = microtime(true);
$url = 'https://www.shuijingwanwq.com/wp-content/uploads/2021/07/ChinaJoy 2015 上海 梦幻西游.mp4';
echo remote_filesize($url) . "\n";
$endTime = microtime(true);
echo '耗费时间:' . ($endTime - $startTime) . '秒';
?>


0
1
3
0
1
2
123596884
耗费时间:0.404137134552秒


6、如果文件的网址不需要 301 跳转,执行顺序如下,仅请求了 1 次。同样的文件:秦时明月第一集荧惑守心.mp4,请求的耗费时间相当,不过现方案略微短于之前的方案。注:时间单位为秒。如图5

如果文件的网址不需要 301 跳转,执行顺序如下,仅请求了 1 次。同样的文件:秦时明月第一集荧惑守心.mp4,请求的耗费时间相当,不过现方案略微短于之前的方案。注:时间单位为秒

图5

<?php
function remote_filesize($url) {
    echo 0 . "\n";
    // 返回一个数组,包含有服务器响应一个 HTTP 请求所发送的标头。
    $filesize = 0;
    $headers = get_headers($url, 1);
 
    if ($headers !== false) {
        echo 1 . "\n";
        if (!isset($headers['Location']) && isset($headers['Content-Length'])) {
            echo 2 . "\n";
            $filesize = $headers['Content-Length'];
        }
        if (isset($headers['Location'])) {
            echo 3 . "\n";
            return remote_filesize($headers['Location']);
        }
    }
 
    return $filesize;
}
 
$startTime = microtime(true);
$url = 'https://www.shuijingwanwq.com/wp-content/uploads/2021/07/秦时明月第一集荧惑守心.mp4';
echo remote_filesize($url) . "\n";
$endTime = microtime(true);
echo '耗费时间:' . ($endTime - $startTime) . '秒';
?>



0
1
2
143162935
耗费时间:0.14869999885559秒


 

]]>
https://www.shuijingwanwq.com/2021/08/11/5166/feed/ 0
通过 FlashFXP 上传后的文件,HTTP 访问时响应 404 的排查分析 https://www.shuijingwanwq.com/2021/07/14/5064/ https://www.shuijingwanwq.com/2021/07/14/5064/#respond Wed, 14 Jul 2021 08:51:34 +0000 https://www.shuijingwanwq.com/?p=5064 Post Views: 67 1、通过 FlashFXP 上传文件:秦时明月第一集荧惑守心.mp4 至:/wp-content/uploads/2021/07/秦时明月第一集荧惑守心.mp4。如图1
通过 FlashFXP 上传文件:秦时明月第一集荧惑守心.mp4 至:/wp-content/uploads/2021/07/秦时明月第一集荧惑守心.mp4

图1

2、HTTP 访问:https://www.shuijingwanwq.com/wp-content/uploads/2021/07/秦时明月第一集荧惑守心.mp4 时响应 404。如图2
HTTP 访问:https://www.shuijingwanwq.com/wp-content/uploads/2021/07/秦时明月第一集荧惑守心.mp4 时响应 404。

图2

3、基于 PuTTY 登录 CentOS 服务器,进入目录:/wp-content/uploads/2021/07/。发现文件:秦时明月第一集荧惑守心.mp4 的文件名乱码。如图3
基于 PuTTY 登录 CentOS 服务器,进入目录:/wp-content/uploads/2021/07/。发现文件:秦时明月第一集荧惑守心.mp4 的文件名乱码。

图3

4、选择“Sites”–下拉菜单中点击“Site Manager”,然后选中站点(这里选择的是www.shuijingwanwq.com),在右侧工具栏中点击“Options”,导航至【Character Encoding】栏,设置为 UTF-8,然后重新连接下即可。如图4
选择“Sites”–下拉菜单中点击“Site Manager”,然后选中站点(这里选择的是www.shuijingwanwq.com),在右侧工具栏中点击“Options”,导航至【Character Encoding】栏,设置为 UTF-8,然后重新连接下即可。

图4

5、重新上传:秦时明月第一集荧惑守心.mp4 至:/wp-content/uploads/2021/07/秦时明月第一集荧惑守心.mp4。在目录:/wp-content/uploads/2021/07/ 下存在 2 个同名的文件。如图5
重新上传:秦时明月第一集荧惑守心.mp4 至:/wp-content/uploads/2021/07/秦时明月第一集荧惑守心.mp4。在目录:/wp-content/uploads/2021/07/ 下存在 2 个同名的文件。

图5

6、登录服务器,进入目录:/wp-content/uploads/2021/07/。删除文件名乱码的文件。如图6
登录服务器,进入目录:/wp-content/uploads/2021/07/。删除文件名乱码的文件。

图6



[root@iZ23wv7v5ggZ 07]# ls

2-4-768x538.png   4-3-720x340.png        ??ʱ???µ?һ??ӫ??????.mp4
2-4-80x80.png     4-3-768x435.png        兔子、牛、还有一只什么哟?认不出来了.mp4
2-4-895x450.png   4-3-80x80.png          发现小区居民楼旁边的主干道都在铺装降噪路面,效果还是挺明显的.mp4
2-4-895x500.png   4-3-980x450.png        发现小区居民楼旁边的主干道都在铺装降噪路面,效果还是挺明显的.webm
2-4.png           4-3.png                数一下,有几只红色的,有几只黄色的呢??.mp4
2-5-1024x515.png  4-4-149x300.png        秦时明月第一集荧惑守心.mp4
2-5-1035x500.png  4-4-150x150.png        精装海景房,您下楼就是这样的景色.mp4
2-5-150x150.png   4-4-320x320.png        龙泉的某个地方打疫苗,人还是这么多了.mp4
[root@iZ23wv7v5ggZ 07]# rm -rf ??ʱ???µ?һ??ӫ??????.mp4
[root@iZ23wv7v5ggZ 07]# ls
2-4-768x538.png   4-3-720x340.png        兔子、牛、还有一只什么哟?认不出来了.mp4
2-4-80x80.png     4-3-768x435.png        发现小区居民楼旁边的主干道都在铺装降噪路面,效果还是挺明显的.mp4
2-4-895x450.png   4-3-80x80.png          发现小区居民楼旁边的主干道都在铺装降噪路面,效果还是挺明显的.webm
2-4-895x500.png   4-3-980x450.png        数一下,有几只红色的,有几只黄色的呢??.mp4
2-4.png           4-3.png                秦时明月第一集荧惑守心.mp4
2-5-1024x515.png  4-4-149x300.png        精装海景房,您下楼就是这样的景色.mp4
2-5-1035x500.png  4-4-150x150.png        龙泉的某个地方打疫苗,人还是这么多了.mp4
2-5-150x150.png   4-4-320x320.png
[root@iZ23wv7v5ggZ 07]#



7、HTTP 访问:https://www.shuijingwanwq.com/wp-content/uploads/2021/07/秦时明月第一集荧惑守心.mp4 时响应 200。如图7
HTTP 访问:https://www.shuijingwanwq.com/wp-content/uploads/2021/07/秦时明月第一集荧惑守心.mp4 时响应 200

图7

 ]]>
https://www.shuijingwanwq.com/2021/07/14/5064/feed/ 0