AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-246768

Zereges's questions

Martin Hope
Zereges
Asked: 2020-09-27 04:00:18 +0800 CST

AllowOverride 不适用于别名站点

  • 0

我有两个域johny.com和alice.com一个管理它们的网络服务器(apache)。Web 文件位于/var/www/johny.com和中,/var/www/alice.com并被配置为两个具有适当ServerName和DocumentRoot. 现在,Alice 想要保护她在网络上的一个文件不被任何人看到。她介绍了一个.htaccess文件,内容如下

<Files "private.txt">
  Require all denied
</Files>

并且还在她的虚拟主机的 apache 配置中添加了以下内容

<Directory /var/www/alice.com>
   Options Indexes FollowSymLinks
   AllowOverride All
</Directory>

并且没有人可以访问alice.com/private.txt. 到目前为止,一切都很好。

现在 John 决定通过更改他的 vhost apache 配置来为 Alice 的 web 提供一个别名

Alias "/alice" "/var/www/alice.com"

任何人都可以在 上看到 Alice 的网页john.com/alice。但是任何人也可以看到爱丽丝私人文件的内容。

alice.com/private.txt给出 403 禁止。
john.com/alice/private.txt显示文件的内容。

这是怎么回事?不通过指令AllowOverride传播?Alias我们应该如何解决这个问题?阿帕奇版本是Apache/2.4.38 (Debian). 将乱码放入.htaccess文件中只会在 500 Internal Server Error 上给出 500 Internal Server Error alice.com,而不是 on john.com/alice,所以似乎.htaccess根本不考虑别名。

alias apache2
  • 1 个回答
  • 1190 Views
Martin Hope
Zereges
Asked: 2015-08-06 02:35:08 +0800 CST

与机器同名的 Apache2 VirtualHost

  • 6

我正在使用 Debian 拥有具有规范名称的服务器(/etc/hostname在反向 DNS 中和反向 DNS 中定义)server.example.com

root@server:~# uname -a
Linux server.example.com 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64 GNU/Linux

Apache/2.4.10 (Debian) 服务器位于 server.example.com 端口 80

现在我安装了 apache2 并做了一些基本的配置。然后我将 VirtualHosts 添加/etc/apache2/sites-available到sites-enabled. 一切正常VirtualHost,除了ServerName server.example.com. 当我尝试在资源管理器中访问该 URI 时,我得到默认虚拟主机的内容(未ServerName指定)。如果我将server.example.com.conf's ServerName 更改为不同的东西(如test.example.com)并重新加载 apache 配置,那么我可以毫无问题地访问 URI。我想知道让 VirtualHostServerName与机器的规范名称相同有什么问题。

另外,server.example.com.conf有DocumentRoot /var/www/subs/server哪些包含index.html和munin文件夹。默认 VirtualHost 中DocumentRoot /var/www/html没有munin文件夹。但是,当我尝试访问时,http://server.example.com/munin我可以进入/var/www/subs/server/munin, whilehttp://server.example.com/index.html给我带来/var/www/html/index.html.

最后,当我放入Redirect 404 /默认的 VirtualHost 时,404当我尝试同时访问http://server.example.com/和http://server.example.com/munin

添加了 VirtualHosts 的配置

/etc/apache2/sites-available/forum.example.com.conf:

# Working subdomain configuration
<VirtualHost *:80>
        ServerName forum.example.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/subs/forum
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

/etc/apache2/sites-available/server.example.com.conf:

# Not working server.example.com configuration
<VirtualHost *:80>
        ServerName server.example.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/subs/server
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

/etc/apache2/sites-available/default.conf:

# Default VirtualHost configuration 
<VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot /var/www/html
        #Redirect 404 /
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

root@server:~# apache2ctl -t
语法OK


添加的输出 root@server:~# apache2 -S

[Tue Aug 11 11:07:32.705684 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Tue Aug 11 11:07:32.706119 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Tue Aug 11 11:07:32.706250 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Tue Aug 11 11:07:32.706406 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Tue Aug 11 11:07:32.706566 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
(... repeating few more times)
[Tue Aug 11 11:07:32.744292 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_LOG_DIR} is not defined

AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

尽管,

/etc/apache2/apache2.conf:74:Mutex file:${APACHE_LOCK_DIR} default
/etc/apache2/envvars:21:export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX


运行后/etc/apache2/envvar我通过执行得到这个apache2 -S

VirtualHost configuration:
*:80     is a NameVirtualHost
         default server server.example.com (/etc/apache2/sites-enabled/default.conf:1)
         port 80 namevhost server.example.com (/etc/apache2/sites-enabled/default.conf:1)
         port 80 namevhost download.example.com (/etc/apache2/sites-enabled/download.example.com.conf:1)
         port 80 namevhost example.com (/etc/apache2/sites-enabled/example.com.conf:1)
                 alias www.example.com
         port 80 namevhost forum.example.com (/etc/apache2/sites-enabled/forum.example.com.conf:1)
         port 80 namevhost forumold.example.com (/etc/apache2/sites-enabled/forumold.example.com.conf:1)
         port 80 namevhost forumtest.example.com (/etc/apache2/sites-enabled/forumtest.example.com.conf:1)
         port 80 namevhost mail.example.com (/etc/apache2/sites-enabled/mail.example.com.conf:1)
         port 80 namevhost ro.example.com (/etc/apache2/sites-enabled/ro.example.com.conf:1)
         port 80 namevhost server.example.com (/etc/apache2/sites-enabled/server.example.com.conf:1)
         port 80 namevhost anotherexample.com (/etc/apache2/sites-enabled/anotherexample.com.conf:1)
                 alias www.anotherexample.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
virtualhost
  • 2 个回答
  • 1947 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve