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

How to understand deny and allow in Apache configuration file

2025-03-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

How to understand the deny and allow in the Apache configuration file, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Summary of deny and allow in Apache configuration file. This article focuses on the execution order of deny and allow. Friends who need it can refer to it.

Today, when the company was configuring the local Apache environment of Zend, I found several sentences in the permission control in zend.conf, as follows:

The code is as follows:

SetHandler server-status

Order deny,allow

Deny from all

Allow from 127.0.0.1

You need to configure VirtualHost when configuring virtual hosts.

The code is as follows:

ServerName backend

DocumentRoot "D:/Program Files/Zend/Apache2/htdocs/public"

SetEnv APPLICATION_ENV "development"

DirectoryIndex index.php

AllowOverride All

Order allow,deny

Allow from all

The difference between the two Order statements interests me, so how exactly is the order executed here? Previously associated with the concept of "short circuit", there are the same, but also different, the following with a few examples to analyze.

The code is as follows:

Order deny,allow

-(note that there is only one comma between deny and allow, and it can only be written this way. All other words are incorrect.)

Allow from all

Deny from 219.204.253.8

All can pass.

The code is as follows:

Order deny,allow

Deny from 219.204.253.8

Allow from all

-all can pass.

The code is as follows:

Order allow,deny

Deny from 219.204.253.8

Allow from all

Only 219.204.253.8 failed.

The code is as follows:

Order allow,deny

Allow from all

Deny from 219.204.253.8

Only 219.204.253.8 failed.

According to the Apache official website, the allow direction affects hosts that can pass through a server zone, which can request conditions through the host name (hostname), IP address, IP address range, or through other clients. On the contrary, deny,deny controls hosts that are not allowed by the server, and deny is identified by hostname (hostname), http://www.bbqmw.net/qm_bbqmbd/IP address and range, or environment variables. The role of the top-level Order is to make the rules. For example, in case 1 above, our Order checks the deny first and then the allow, then we can treat the following two sentences as a list. There is no natural order for these two sentences, that is, when we check the deny, we find that the host 219.204.253.8 meets the rejection condition, so we do the second step test, that is, the allow check, and we find that what the allow does is: allow from all It means that all sources can be approved. The key here is that all visitors are not killed with a stick and have to go through two steps of verification, so it can be found that all machines can be passed, consistent with the results.

After reading the above, have you mastered how to understand deny and allow in the Apache configuration file? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

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: 243

*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