0

我试图允许在我的 Apache 2.2.3 (Centos) 服务器上访问单个位置(不存在的文件),以便能够实现 paypal ipn 侦听器。其他文件应保持密码保护。

如何允许在不登录的情况下访问单个位置?

下面的代码显示了我到目前为止所做的尝试。

location 指令选择正确的位置(我通过向它写入拒绝来测试它)。

现在遇到的问题是服务器仍在询问该位置的密码

我已经尝试将位置指令放入目录一,但这会导致语法错误(即使文件指令允许这样做)但我不能使用文件指令代替位置一,因为文件实际上并不存在.

<Directory /var/www/vhosts/somedomain.net/subdomains/p103.myproject/httpdocs/public>
Order Deny,Allow
 Options -Includes -ExecCGI
 SetEnv APPLICATION_ENV "development"
 AuthName "myproject"
 AuthType Basic
 AuthUserFile /var/www/vhosts/somedomain.net/subdomains/p103.myproject/.htpasswd
 AuthGroupFile /var/www/vhosts/somedomain.net/subdomains/p103.myproject/.htgroups
 Require group myproject
</Directory>
DocumentRoot /var/www/vhosts/somedomain.net/subdomains/p103.myproject/httpdocs/public
<Location "/ipn/sdsad8329ejslkdjasl">
 Order Deny,Allow
 Allow from all
 Satisfy Any
</Location>

这里是文档的链接:http ://httpd.apache.org/docs/2.2/

4

1 回答 1

1

您可以使用 aSetEnvIf来匹配 Request_URI 以设置变量,然后使用Satisfy anyRequire group myproject的组合Allow

尝试这样的事情:

DocumentRoot /var/www/vhosts/somedomain.net/subdomains/p103.myproject/httpdocs/public

# Here we check if the request is for something we don't need to authorize
SetEnvIf Request_URI ^/ipn/sdsad8329ejslkdjasl NO_AUTH_NEEDED=1

<Directory /var/www/vhosts/somedomain.net/subdomains/p103.myproject/httpdocs/public>
  Order Allow,Deny
  Options -Includes -ExecCGI
  SetEnv APPLICATION_ENV "development"
  AuthName "myproject"
  AuthType Basic
  AuthUserFile /var/www/vhosts/somedomain.net/subdomains/p103.myproject/.htpasswd
  AuthGroupFile /var/www/vhosts/somedomain.net/subdomains/p103.myproject/.htgroups

  # This makes it so one of the 2 is good enough
  Satisfy Any
  # We allow first, but only if the NO_AUTH_NEEDED is set
  Allow from env=NO_AUTH_NEEDED
  # Otherwise, require a login
  Require group myproject

</Directory>
于 2011-11-17T01:53:50.190 回答