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

用wordpress做网站页面显示404/今日头条最新

用wordpress做网站页面显示404,今日头条最新,网站优化怎么做效果才好,汽车精品网站建设参考代码 https://gitee.com/xiaoyun461/blocking-external-networks首先 需要的依赖: libmaxminddb https://github.com/maxmind/libmaxminddbmaxmind-geoip https://github.com/Dreamacro/maxmind-geoiplibmaxminddb 需要gcc编译,可用 Dockerfile …

参考代码

https://gitee.com/xiaoyun461/blocking-external-networks

首先 需要的依赖:

libmaxminddb

https://github.com/maxmind/libmaxminddb

maxmind-geoip

https://github.com/Dreamacro/maxmind-geoip

libmaxminddb 需要gcc编译,可用 Dockerfile 里面编译生成so文件,然后复制到 openresty/openresty:centos-rpm 镜像中,然后把 Country.mmdb(Ip数据库) 也复制到镜像中

Dockerfile 如下:

############## 构建 libmaxminddb #####################
FROM gcc:9 AS libmaxminddb-build
ADD lib/libmaxminddb-1.8.0.tar.gz /
WORKDIR /libmaxminddb-1.8.0
RUN ./configure && make && make install && ldconfig -v && ls -f  /usr/local/lib/libmaxminddb*############## 构建 openresty #####################
FROM openresty/openresty:centos-rpm
ENV TZ Asia/Shanghai
COPY --from=libmaxminddb-build   /usr/local/lib/libmaxminddb.so.0.0.7 /lib64
COPY  geoip/20231212/Country.mmdb /etc/nginx/mmdb/Country.mmdbRUN  ln -snf /usr/share/zoneinfo/"$TZ" /etc/localtime && echo "$TZ" > /etc/timezone \&& opm get anjia0532/lua-resty-maxminddb \&& ln -s /lib64/libmaxminddb.so.0.0.7 /lib64/libmaxminddb.so \&& ldconfig -v

然后配置lua脚本,OpenResty(也称为 ngx_openresty)是一个基于 Nginx 与 Lua 的高性能 Web 平台,

lua脚本如下:

local function get_client_ip()local headers = ngx.req.get_headers()local clientIP = headers["x-forwarded-for"]if clientIP == nil or string.len(clientIP) == 0 or clientIP == "unknown" thenclientIP = headers["Proxy-Client-IP"]endif clientIP == nil or string.len(clientIP) == 0 or clientIP == "unknown" thenclientIP = headers["WL-Proxy-Client-IP"]endif clientIP == nil or string.len(clientIP) == 0 or clientIP == "unknown" thenclientIP = ngx.var.remote_addrend-- 对于通过多个代理的情况,第一个IP为客户端真实IP,多个IP按照','分割if clientIP ~= nil and string.len(clientIP) > 15 thenlocal pos = string.find(clientIP, ",", 1)clientIP = string.sub(clientIP, 1, pos - 1)endreturn clientIP;
endlocal function check_cn(ip)local geo = require 'resty.maxminddb'if not geo.initted() thengeo.init("/etc/nginx/mmdb/Country.mmdb")endlocal res, err = geo.lookup(ip)if not res thenngx.log(ngx.ERR, ' failed to lookup by ip , reason :', err)elsefor k, v in pairs(res) doif (k == "country") thenfor key, item in pairs(v) doif (key == "iso_code") thenif item == "CN" thenngx.log(ngx.INFO, ' this counrty: ', item)return 1;elsengx.log(ngx.ERR, ' this counrty: ', item)return 0;endendendendendend
end-- 获取nginx 本地缓存
local cache_ngx = ngx.shared.dis_cache;
-- 获取 请求IP
local clientIP = get_client_ip();--根据IP 获取本地黑名单缓存数据
local banIpCache = cache_ngx:get('ban_ip_' .. clientIP);
if banIpCache == 1 thenngx.log(ngx.ERR, "cache_black_ip:", clientIP)ngx.exit(403)
else-- 判断是否是国外IP, 直接设为黑名单,并且返回403local flag = check_cn(clientIP);if flag == 0 then-- 本地缓存黑名单 时间1小时ngx.log(ngx.ERR, "set_local_black_ip:", clientIP)cache_ngx:set('ban_ip_' .. clientIP, 1, 60 * 60);ngx.exit(403)end
end

nginx.conf 配置文件 也要加入 lua脚本校验,以及 增加128M的本地缓存,方便过滤

nginx.conf如下:

pcre_jit on;#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;error_log  logs/error.log  warn;#pid        logs/nginx.pid;worker_processes auto;events {worker_connections  20480;
}http {include       mime.types;default_type  application/octet-stream;# Enables or disables the use of underscores in client request header fields.# When the use of underscores is disabled, request header fields whose names contain underscores are marked as invalid and become subject to the ignore_invalid_headers directive.# underscores_in_headers off;log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log  /dev/stdout  main;#         Log in JSON Formatlog_format nginxlog_json escape=json '{ "timestamp": "$time_local", ''"remote_addr": "$remote_addr", ''"remote_user": "remote_user", ''"body_bytes_sent": $body_bytes_sent, ''"request_time": $request_time, ''"response_status": $status, ''"request": "$request", ''"request_method": "$request_method", ''"host": "$host",''"upstream_addr": "$upstream_addr",''"upstream_host": "$upstream_http_host",''"upstream_resp_time": "$upstream_response_time",''"http_x_forwarded_for": "$http_x_forwarded_for",''"http_referrer": "$http_referer", ''"http_user_agent": "$http_user_agent", ''"http_version": "$server_protocol" ';map $time_iso8601 $logdate {'~^(?<ymd>\d{4}-\d{2}-\d{2})' $ymd;default                       'date-not-found';}access_log logs/access_json-$logdate.log  nginxlog_json;# See Move default writable paths to a dedicated directory (#119)# https://github.com/openresty/docker-openresty/issues/119client_body_temp_path /var/run/openresty/nginx-client-body;proxy_temp_path       /var/run/openresty/nginx-proxy;fastcgi_temp_path     /var/run/openresty/nginx-fastcgi;uwsgi_temp_path       /var/run/openresty/nginx-uwsgi;scgi_temp_path        /var/run/openresty/nginx-scgi;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;client_max_body_size 150m;#     lua cachelua_shared_dict dis_cache 128m;gzip on;gzip_static  on;gzip_min_length 1k;     # 设置允许压缩的页面最小字节数gzip_buffers 4 16k;     # 用来存储 gzip 的压缩结果gzip_http_version 1.1;  # 识别 HTTP 协议版本gzip_comp_level 2;      # 设置 gzip 的压缩比 1-9。1 压缩比最小但最快,而 9 相反gzip_types gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; # 指定压缩类型gzip_proxied any;       # 无论后端服务器的 headers 头返回什么信息,都无条件启用压缩# 限制国外ipaccess_by_lua_file /etc/nginx/lua/access_limit_open.lua;include /etc/nginx/conf.d/*.conf;}

全部 样例代码 在

https://gitee.com/xiaoyun461/blocking-external-networks

可自行修改

相关文章:

如何通过openresty 限制国外Ip访问

参考代码 https://gitee.com/xiaoyun461/blocking-external-networks首先 需要的依赖&#xff1a; libmaxminddb https://github.com/maxmind/libmaxminddbmaxmind-geoip https://github.com/Dreamacro/maxmind-geoiplibmaxminddb 需要gcc编译&#xff0c;可用 Dockerfile …...

【Vue2】一个数组按时间分割为【今年】和【往年】俩个数组

一. 需求 后端返回一个数组&#xff0c;前端按时间维度将该数组的分割为【今年】和【往年】俩个数组后端返回的数组格式如下 timeList:[{id:1,billTime:"2024-01-10",createTime:"2024-01-10 00:00:00",status:0},{id:2,billTime:"2022-05-25"…...

解决鸿蒙APP的内存泄漏

解决鸿蒙&#xff08;HarmonyOS&#xff09;应用的内存泄漏问题需要采用一系列的策略和技术。与解决Android内存泄漏类似&#xff0c;以下是一些建议&#xff0c;希望对大家有所帮助。北京木奇移动技术有限公司&#xff0c;专业的软件外包开发公司&#xff0c;欢迎交流合作。 1…...

云原生专栏大纲

1. 私有云实战之基础环境搭建 2. 云原生实战之kubesphere搭建 3.云原生之kubesphere运维 4. 云原生之kubesphere基础服务搭建 5.云原生安全之kubesphere应用网关配置域名TLS证书 6.云原生之DevOps和CICD 7.云原生之jenkins集成SonarQube 8.云原生存储之Ceph集群 9.云原生存储之…...

robot_framework的robot语法与python脚本之间的语法转换

Robot Framework是一个开源的自动化测试框架&#xff0c;支持关键字驱动和数据驱动的测试方法。它具有简单易学的语法和丰富的库&#xff0c;可以与多种语言进行集成&#xff0c;包括Python。 1. robot 的关键字 Robot Framework 是一个用于自动化测试和自动化任务的开源框架…...

D1675滤波器和缓冲器用于单通道6阶高清视频滤波驱动电路,可提高视频信号性能

D1675单电源工作电压为2.5V到5V&#xff0c;是一款高清视频信号译码、编码的滤波器和缓冲器。与使用分立元件的传统设计相比&#xff0c;D1675更能节省PCB板面积&#xff0c;并降低成本以及提高视频信号性能。D1675集成了一个直流耦合输入缓冲器、一个消除带外噪声的视频编码器…...

Java18:网络编程

一.对象序列化&#xff1a; 1.对象流&#xff1a; ObjectInputStream 和 ObjectOutputStream 2.作用&#xff1a; ObjectOutputSteam&#xff1a;内存中的对象-->存储中的文件&#xff0c;通过网络传输出去 ObjectInputStream:存储中的文件&#xff0c;通过网络传输出去…...

【Python百宝箱】模拟未见之境:精准工具畅游分子动力学风景

分子演绎&#xff1a;模拟工具的综合探索 前言 在当今科学研究中&#xff0c;分子动力学模拟成为解析原子和分子行为的关键工具之一。本文将深入探讨几种领先的分子动力学模拟工具&#xff0c;包括MDTraj、ASE&#xff08;原子模拟环境&#xff09;、OpenMM和CHARMM。这些工具…...

Vue 3面试题

Vue 3面试题 以下是一些常见的Vue 3面试题&#xff1a; Vue 3中的Composition API是什么&#xff1f;它与Options API有什么区别&#xff1f; 答案&#xff1a; Composition API是Vue 3中引入的一种新的组件设计模式&#xff0c;它允许开发者通过函数的形式组织和重用组件的逻…...

M-A352AD10高精度三轴加速度计

一般描述 M-A352是一种三轴数字输出加速度计&#xff0c;具有超低噪声、高稳定性、低功耗等特点&#xff0c;采用了夸特的精细处理技术。. 多功能M-A352具有高精度和耐久性&#xff0c;非常适合广泛的具有挑战性的应用&#xff0c;如SHM、地震观测、工业设备的状态监测和工业…...

(1)(1.13) SiK无线电高级配置(七)

文章目录 前言 17 技术细节 18 名词解释 前言 本文提供 SiK 遥测无线电(SiK Telemetry Radio)的高级配置信息。它面向"高级用户"和希望更好地了解无线电如何运行的用户。 17 技术细节 在评估该无线电是否符合当地法规时&#xff0c;了解其使用的技术可能会有所帮…...

如何注释 PDF?注释PDF文件方法详情介绍

大多数使用 PDF 文档的用户都熟悉处理这种格式的文件时出现的困难。有些人仍然认为注释 PDF 的唯一方法是打印文档&#xff0c;使用笔或荧光笔然后扫描回来。 您可能需要向 PDF 添加注释、添加注释、覆盖一些文本或几何对象。经理、部门负责人在编辑公司内的合同、订单、发票或…...

GEE APP——基于PFI纯净森林指数的CCDC-SMA算法的长时序森林监测APP

简介 森林生态系统的碳排放受到破碎化加速和边缘效应的极大影响。要了解这些影响,就必须准确监测破碎化森林景观的变化。然而,这些变化通常强度低、尺度小,因此很难使用中等空间分辨率的卫星图像(如 Landsat)来检测。为了应对这一挑战,本研究开发了纯林指数(PFI),该指…...

CF1446B Catching Cheaters 题解 DP

Catching Cheaters 传送门 题面翻译 给我们两个字符串&#xff0c;让我们从中选出两个字串&#xff0c;算出它们的最大公共子序列长度。然后将它乘 4 4 4在减去两个字串的长度。问你这个数最大是多少。 题目描述 You are given two strings A A A and B B B representin…...

用python实现文本/图片生成视频

使用Python来生成视频通常涉及到使用一些专门的库&#xff0c;比如 OpenCV 或者 moviepy。下面是一个简单的例子&#xff0c;使用OpenCV和PIL&#xff08;Python Imaging Library&#xff09;来创建一个视频。 python复制代码 import cv2 import numpy as np from PIL import …...

Android Gradle Plugin、Gradle、Android Studio版本关系

参考链接 Android Gradle Plugin 与 gradle 对应关系 插件版本所需的最低 Gradle 版本8.38.48.28.28.18.08.08.07.47.57.37.47.27.3.37.17.27.07.04.2.06.7.14.1.06.54.0.06.1.13.6.0 - 3.6.45.6.43.5.0 - 3.5.45.4.13.4.0 - 3.4.35.1.13.3.0 - 3.3.34.10.13.2.0 - 3.2.14.63…...

PyTorch深度学习实战(30)——Deepfakes

PyTorch深度学习实战&#xff08;30&#xff09;——Deepfakes 0. 前言1. Deepfakes 原理2. 数据集分析3. 使用 PyTorch 实现 Deepfakes3.1 random_warp.py3.2 Deepfakes.py 小结系列链接 0. 前言 Deepfakes 是一种利用深度学习技术生成伪造视频和图像的技术。它通过将一个人的…...

java 修改JsonObject对象所有的Value类型为String

将JSONObject 或者JSONArray 中所有Value 为数值类型 转为String. 转换前: [{"zjlx": 201,"xm": "刘**","cbdjxxlist": [{"zspmdm": 102031201,"rybm": "43000010300000411195","jfrlx": 1…...

Vue3-47-Pinia-修改全局状态变量值的方式

说明 修改全局状态变量的值&#xff0c;是一个比较常规而且常见的操作。 本文就介绍四种常见的操作。 由于Option Store 和Setup Store 在修改的时候略有不同&#xff0c;所以本文也会将不同点体现一下。 全局状态变量的定义 包含了 Option Store 和Setup Store 两种定义方式&a…...

【Scala】——面向对象

1 Scala 包 1.1 包风格 Scala 有两种包的管理风格。 第一种 Java 的包管理风格相同&#xff0c;每个源文件一个包&#xff08;包 名和源文件所在路径不要求必须一致&#xff09;&#xff0c;包名用“.”进行分隔以表示包的层级关系&#xff0c;如 com.atguigu.scala。另一种风…...

【MediaFoundation】OpenCV VideoCapture 读取音频源码

OpenCV 读取音频代码实例 在windows7 以及OpenCV4 过后可以使用 CAP_MSMF 读取音频&#xff0c;但是OpenCV没有播放音频的API。代码示例如下。 本文解析OpenCVCAP_MSMF 进行文件、设备的 音频读取&#xff0c;学习MediaFoundation 的使用。 #include <opencv2/core.hpp>…...

2024秋招,百度测试开发工程师一面

前言 大家好&#xff0c;今天我来回顾一下秋招中的一场很重要技术面试 一面面试官深挖我的项目经历&#xff0c;并提出了很多的实际场景&#xff0c;我现在回顾依然有很多新的认识 过程 自我介绍实习工作中&#xff0c;做得最好的地方是什么&#xff1f; 我先介绍了一下实习…...

Git 使用与问题记录 二(公司快速上手版)

写在前面 记录自己学习的内容&#xff0c;方便后面忘记的时候查看。给像我一样的新手提供一点参考 正文 上一章已经安装好了Git&#xff0c;如何使用呢。我这里会分享两种办法&#xff0c;第一种是在VS2022中克隆代码&#xff0c;修改和提交&#xff1b;第二种是用命令提交。…...

【C语言小游戏】贪吃蛇

文章目录 1.引言2.运行图2.涉及知识3 Windows API3.1 控制台3.2 控制台屏幕坐标3.3 操作句柄3.4 控制台屏幕光标3.5 监视按键 4. 设计说明5. 完整代码 1.引言 使⽤C语⾔在Windows环境的控制台中模拟实现经典⼩游戏贪吃蛇 实现基本的功能&#xff1a; 贪吃蛇地图绘制蛇吃⻝物的…...

价值7500的在线授权网站源码支持IP+域名+双向授权全开源

PHP授权验证更新系统完整版&#xff0c;一键更新系统&#xff0c;一键卡密生成自助授权功能&#xff0c;域名ip双重验证功能等等 修复盗版检测&#xff0c;确保实时查看盗版 修复在线加密系统&#xff0c;一键加密 授权系统几乎所有的程序都能整合使用,包括您的app和计算机程序…...

haiku实现门控多头注意力模块

在多头注意力机制中&#xff0c;通常输入的数据包括查询&#xff08;Q&#xff09;、键&#xff08;K&#xff09;和值&#xff08;V&#xff09;。这些数据的维度以及权重矩阵的维度在多头注意力机制中扮演关键角色。下面对数据及权重的维度进行解释&#xff1a; 输入数据&…...

【React 常用的 TS 类型】持续更新

1&#xff09;定义样式的 TS 类型 【 React.CSSProperties 】 一般定义样式时需要的类型限制&#xff0c;如下&#xff1a; const customStyle: React.CSSProperties {color: blue,fontSize: 16px,margin: 10px,}; 2&#xff09;定义 Input Ref 属性时的 TS 类型限制 【 R…...

打破传统边界,VR技术与六西格玛设计理念的创新融合!

在科技飞速发展的今天&#xff0c;虚拟现实&#xff08;VR&#xff09;技术以其独特的沉浸式体验&#xff0c;正在改变我们的生活和工作方式。然而&#xff0c;要让VR真正成为主流&#xff0c;我们必须解决一些关键问题&#xff0c;其中最重要的就是用户体验。六西格玛设计&…...

[uniapp] uni-ui+vue3.2小程序评论列表组件 回复评论 点赞和删除

先看效果 下载地址 uni-app官方插件市场: cc-comment组件 环境 基于vue3.2和uni-ui开发; 依赖版本参考如下: "dependencies": {"dcloudio/uni-mp-weixin": "3.0.0-3090820231124001","dcloudio/uni-ui": "^1.4.28","…...

TongLINKQ(3):TongLINKQ常用命令

启动&#xff1a; tlq 暂停&#xff1a; tlq -cabort -y -w1 查看lic信息&#xff1a; tlqstat –lic 查看队列消息&#xff1a; tlqstat -qcu qcu名 -c 查看发送连接状态&#xff1a; tlqstat -snd qcu名 -1 -ct 1 查看指定的Qcu连接状态&#xff1a; tlqsta…...