Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Use nginx to regularly intercept specified url requests

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the method of using nginx to regularly intercept specified url requests, the content is clear, interested partners can learn, I believe it will be helpful after reading.

Nginx server

Nginx is an excellent web server, which is very efficient in dealing with static files, and its proxy forwarding function is very simple and efficient with other back-end servers.

Location

We know that nginx will parse the request and get the url and other information about the request. We just need to match the url and intercept it.

Matching rule

Location / {if ($request_uri ~ * ^ /\? http (. *) $) {return 404;}}

After such a match, we can intercept all the URLs of the request root directory and similar requests with a parameter of? httpxxx will display 404.

Hotlink protection

Return http code, such as setting nginx hotlink protection:

Location ~ *\. (gif | jpg | png | swf | flv) ${valid_referers none blocked www.80shihua.com www.menghuiguli.com; if ($invalid_referer) {return 404;}}

Nginx common variables

Nginx parses a lot of variables that we often use, and we just need to take them over and use them. Here are the variables commonly used by nginx. For specific usage, you can refer to the official documentation.

$content_length

$content_type

$cookie_

$date_gmt

$date_local

$document_root

$document_uri

$fastcgi_path_info

$fastcgi_script_name

$gzip_ratio

$host

$hostname (ngx_http_core_module)

$hostname (ngx_stream_core_module)

$http2

$http_

$protocol

$proxy_host

$proxy_port

$query_string

$realpath_root

$request

$request_body

$request_uri

$scheme

$server_name

$uri

After reading the above, do you have a better understanding of the method of using nginx to regularly intercept specified url requests? if you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report