【问题标题】:MacOS Dnsmasq High Sierra 403 Forbidden errorMacOS Dnsmasq High Sierra 403 禁止错误
【发布时间】:2017-12-29 16:21:05
【问题描述】:

我尝试使用全新干净的 macOS High Sierra 10.13.2 配置 dnsmasq

Apache 版本

Server version: Apache/2.4.28 (Unix)
Server built:   Oct  9 2017 19:54:20
apachectl configtest
Syntax OK

我曾经拥有它并且工作正常。但我认为我遗漏了一些东西,因为我在 localhost、127.0.0.1 和任何项目(如 home.test 或anything.test)上收到 403 禁止错误

Forbidden
You don't have permission to access / on this server.

我取消了必要的文件以使其工作:

httpd.conf

Include /private/etc/apache2/extra/httpd-vhosts.conf
Include /private/etc/apache2/extra/httpd-userdir.conf
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule php7_module libexec/apache2/libphp7.so
User absolutkarlos
Group staff
ServerName localhost
Directory > AllowOverride None
Directory > Options FollowSymLinks Multiviews Indexes

dnsmasq.conf

address=/test/127.0.0.1

absolutkarlos.conf

Directory "/Users/absolutkarlos/DOC/www/sites/"
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted

httpd-userdir.conf

UserDir sites
Include /private/etc/apache2/users/*.conf

httpd-vhosts.conf

<Directory "/www">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Require all granted
</Directory>

<Virtualhost *:80>
VirtualDocumentRoott "/Users/absolutkarlos/DOC/www/home/wwwroot"
ServerName home.test
UseCanonicalName Off
</Virtualhost>

<Virtualhost *:80>
VirtualDocumentRoot "/Users/absolutkarlos/DOC/www/sites/%1/wwwroot"
ServerName sites.test
ServerAlias *.test
UseCanonicalName Off
</Virtualhost>

error_log

AH01630: client denied by server configuration: /Users/absolutkarlos/DOC/www/home, referer: http://home.test/
AH01630: client denied by server configuration: /Users/absolutkarlos/DOC/www/home, referer: http://localhost/
AH01630: client denied by server configuration: /Users/absolutkarlos/DOC/www/home, referer: http://127.0.0.1/

任何 ping 都可以正常工作

ping

ping -c 1 home.test
PING home.test (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.035 ms

--- home.test ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.035/0.035/0.035/0.000 ms

【问题讨论】:

  • 你来对了吗?我也有同样的问题。

标签: macos apache dnsmasq


【解决方案1】:

如果您在使用 dnsmasq 时执行此操作(不是创建动态虚拟主机,而是将每个虚拟主机添加到您的 httpd-vhost 文件中),请确保在您的 httpd.conf 文件中,DocumentRoot 指令指向您所在目录之上的一个目录正在创建您的项目。

即: /用户/我的用户/项目/

  • 博客
  • 项目2
  • 测试项目

在您的 httpd-vhosts.conf 文件中

<VirtualHost *:80>
    DocumentRoot "/Users/MyUser/Projects/blog"
    ServerName blog.test
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Users/MyUser/Projects/project2"
    ServerName project2.test
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Users/MyUser/Projects/testproject"
    ServerName testproject.test
</VirtualHost>

然后,在 httpd.conf 中(大约第 248 行):

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/Users/MyUser/Projects/"
<Directory "/Users/MyUser/Projects/">

如果您的项目不直接位于 /Users/MyUser/Projects 下,Apache 将回退到您的系统访问指令,默认情况下,拒绝访问(大约第 230 行):

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

【讨论】:

    猜你喜欢
    • 2018-08-14
    • 2017-01-30
    • 1970-01-01
    • 2019-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多