LNMP简单的一些防CC的办法
最近一直在研究这方面的配置,只是脚本比较复杂。在网上用力找了几天,主要教程还是那些东西。并且有点乱七八糟,小夜进行了 一些 整理。告诉你最 简单 的方法,来实现这二个方面的内容: nginx最 简单 的反向代理脚本 nginx最 简单 的前端缓存反向代理脚本
最近一直在研究这方面的配置,只是脚本比较复杂。在网上用力找了几天,主要教程还是那些东西。并且有点乱七八糟,小夜进行了一些整理。告诉你最简单的方法,来实现这二个方面的内容:
- nginx最简单的反向代理脚本
- nginx最简单的前端缓存反向代理脚本
- 只提供简单应用,自动更新等操作不讲解
- 最简单的脚本,容易学会到渣
切记:配置完成后,需要刷新nginx配置,以下2条命令都可以:
/root/lnmp reload /etc/init.d/nginx reload
一、最简单的反向代理脚本(只要修改2个网址,存成conf文件放置于vhost下):
server { listen 80; server_name www.vpsmm.com; location / { proxy_pass http://cache.vpsmm.com/; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
二、最简单的前端全缓存,反向代理脚本
#新建2个目录,放置缓存文件: mkdir /home/cache/path -p mkdir /home/cache/temp -p
修改 /usr/local/nginx/conf/nginx.conf 新增以下代码,主要是缓存相关设置,请放置于 http{ ##这里 } 中,一般加在 log_format 上面或下面均可:
client_body_buffer_size 512k; proxy_connect_timeout 5; proxy_read_timeout 60; proxy_send_timeout 5; proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 128k; proxy_temp_path /home/cache/temp; proxy_cache_path /home/cache/path levels=1:2 keys_zone=cache_one:500m inactive=7d max_size=30g; #500m是内存占用,7d是7天无访问删除,30g是缓存占具硬盘空间
以下为虚拟主机配置文件,可另存成 .conf 放置于 vhost 下面:
server { listen 80; server_name www.vpsmm.com; #主机名 location / { proxy_cache cache_one; proxy_cache_valid 200 304 3d; #正常状态缓存时间3天 proxy_cache_key $host$uri$is_args$args; proxy_pass http://cache.vpsmm.com/; #反代的网站 proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; expires 10d; #默认10天缓存 access_log /home/wwwlogs/vpsmm.log access; #日志文件 } }
点击几下网站,df -sh 命令,查看 /home/cache 目录大小,即可测试是否缓存成功。此脚本为前端全缓存,后端动态更新后,前端不会自动修改。可手动清理cache目录下文件。这个方法,可以用纯静态的形式来防CC,如果你的动态博客,受到CC攻击,可以尝试一下。
三、LNMP简单的一些防CC的办法
观看生成的.log日志文件,判断来路,直接301百度:
if ($http_referer ~* mi5.gov ) { rewrite ^(.*)$ http://www.baidu.com/ permanent; }
观看生成的.log日志文件,判断浏览器特征码,直接301百度:
if ($http_user_agent ~* firefox4.0 ) { rewrite ^(.*)$ http://www.baidu.com/ permanent; }
根据特征码,直接查找.log文件,并iptables封死相应IP:
cat com.log | grep 'Mozilla/5.0' | awk '{print "iptables -I INPUT -p tcp --dport 80 -s ", $1, "-j DROP"}'| sort -n | uniq | sh

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The hard disk serial number is an important identifier of the hard disk and is usually used to uniquely identify the hard disk and identify the hardware. In some cases, we may need to query the hard drive serial number, such as when installing an operating system, finding the correct device driver, or performing hard drive repairs. This article will introduce some simple methods to help you check the hard drive serial number. Method 1: Use Windows Command Prompt to open the command prompt. In Windows system, press Win+R keys, enter "cmd" and press Enter key to open the command

What graphics card is good for Core i73770? RTX3070 is a very powerful graphics card with excellent performance and advanced technology. Whether you're playing games, rendering graphics, or performing machine learning, the RTX3070 can handle it with ease. It uses NVIDIA's Ampere architecture, has 5888 CUDA cores and 8GB of GDDR6 memory, which can provide a smooth gaming experience and high-quality graphics effects. RTX3070 also supports ray tracing technology, which can present realistic light and shadow effects. All in all, the RTX3070 is a powerful and advanced graphics card suitable for those who pursue high performance and high quality. RTX3070 is an NVIDIA series graphics card. Powered by 2nd generation NVID

Large-scale language models (LLMs) have demonstrated compelling capabilities in many important tasks, including natural language understanding, language generation, and complex reasoning, and have had a profound impact on society. However, these outstanding capabilities require significant training resources (shown in the left image) and long inference times (shown in the right image). Therefore, researchers need to develop effective technical means to solve their efficiency problems. In addition, as can be seen from the right side of the figure, some efficient LLMs (LanguageModels) such as Mistral-7B have been successfully used in the design and deployment of LLMs. These efficient LLMs can significantly reduce inference memory while maintaining similar accuracy to LLaMA1-33B

3nm process, performance surpasses H100! Recently, foreign media DigiTimes broke the news that Nvidia is developing the next-generation GPU, the B100, code-named "Blackwell". It is said that as a product for artificial intelligence (AI) and high-performance computing (HPC) applications, the B100 will use TSMC's 3nm process process, as well as more complex multi-chip module (MCM) design, and will appear in the fourth quarter of 2024. For Nvidia, which monopolizes more than 80% of the artificial intelligence GPU market, it can use the B100 to strike while the iron is hot and further attack challengers such as AMD and Intel in this wave of AI deployment. According to NVIDIA estimates, by 2027, the output value of this field is expected to reach approximately

i73770 with rx5600xt Because the RX5600XT graphics card is matched with the R53600CPU, we chose the i7-3770. The evaluation results of the RX5600XT graphics card are as follows: The RX5600XT graphics card is an excellent graphics card and performed very well after testing. It adopts AMD's RDNA architecture, has 6GBGDDR6 video memory and 192-bit memory interface, supports PCIe4.0 bus, and has excellent gaming performance. In all tests, the RX5600XT graphics card performed well. At high resolutions, it delivers a smooth gaming experience and maintains frame rates above 60 FPS in most games. In the latest games, it can also provide good

How to write a simple student performance report generator using Java? Student Performance Report Generator is a tool that helps teachers or educators quickly generate student performance reports. This article will introduce how to use Java to write a simple student performance report generator. First, we need to define the student object and student grade object. The student object contains basic information such as the student's name and student number, while the student score object contains information such as the student's subject scores and average grade. The following is the definition of a simple student object: public

The most comprehensive review of multimodal large models is here! Written by 7 Chinese researchers at Microsoft, it has 119 pages. It starts from two types of multi-modal large model research directions that have been completed and are still at the forefront, and comprehensively summarizes five specific research topics: visual understanding and visual generation. The multi-modal large-model multi-modal agent supported by the unified visual model LLM focuses on a phenomenon: the multi-modal basic model has moved from specialized to universal. Ps. This is why the author directly drew an image of Doraemon at the beginning of the paper. Who should read this review (report)? In the original words of Microsoft: As long as you are interested in learning the basic knowledge and latest progress of multi-modal basic models, whether you are a professional researcher or a student, this content is very suitable for you to come together.

How to write a simple online reservation system through PHP. With the popularity of the Internet and users' pursuit of convenience, online reservation systems are becoming more and more popular. Whether it is a restaurant, hospital, beauty salon or other service industry, a simple online reservation system can improve efficiency and provide users with a better service experience. This article will introduce how to use PHP to write a simple online reservation system and provide specific code examples. Create database and tables First, we need to create a database to store reservation information. In MyS
