我正在运行一个幽灵网站,该网站由 apache 使用 vhost 中的代理作为前端。
但是,我知道有一个额外的文件夹我需要提供访问权限 - icookie
:
[root@gce ~]# ls -l /var/www/html/blog
total 252
-rw-r--r--. 1 apache apache 4511 Feb 27 2017 config.example.js
-rw-r--r--. 1 apache apache 4510 May 2 20:51 config.js
drwxr-xr-x. 6 apache apache 4096 Feb 27 2017 content
drwxr-xr-x. 5 apache apache 4096 Feb 27 2017 core
-rw-r--r--. 1 apache apache 31937 Feb 27 2017 Gruntfile.js
**drwxrwxr-x. 3 apache apache 4096 Oct 20 22:37 icookie <-------
-rw-r--r--. 1 apache apache 725 Feb 27 2017 index.js
-rw-r--r--. 1 apache apache 1065 Feb 27 2017 LICENSE
drwxr-xr-x. 109 apache apache 4096 Feb 27 2017 node_modules
-rw-r--r--. 1 apache apache 166948 Feb 27 2017 npm-shrinkwrap.json
-rw-r--r--. 1 apache apache 3047 Feb 27 2017 package.json
-rw-r--r--. 1 apache apache 2942 Feb 27 2017 PRIVACY.md
-rw-r--r--. 1 apache apache 4710 Feb 27 2017 README.md
但是,在将以下配置添加到 apache 后,我仍然无法访问 icocookie 文件夹中的任何文件。据我所知,以下内容应该有效。
<VirtualHost *:443>
ServerName website.com
ServerAlias direct.website.com www.website.com
ProxyPass /icookie !
Alias /icookie /var/www/html/blog/icookie
<Directory /var/www/html/blog/icookie>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ProxyPass / http://10.240.0.3:2369/
ProxyPassReverse / http:/10.240.0.3:2369/
ErrorLog #########
CustomLog ######### common
SSLEngine on
SSLCertificateFile ############
SSLCertificateKeyFile ########
</VirtualHost>
有什么想法吗?
最佳答案
在 ProxyPassReverse
指令中,第二个参数在协议(protocol)名称和 IP 地址之间缺少一个 /
字符。
if you are creating an Alias to a directory outside of your DocumentRoot, you may need to explicitly permit access to the target directory.
Alias "/image" "/ftp/pub/image" <Directory "/ftp/pub/image"> Require all granted </Directory>
对于您的示例,您可能需要像这样添加 Require
指令:
<VirtualHost *:443>
ServerName website.com
ServerAlias direct.website.com www.website.com
ProxyPass /icookie !
Alias /icookie /var/www/html/blog/icookie
<Directory /var/www/html/blog/icookie>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
ProxyPass / http://10.240.0.3:2369/
ProxyPassReverse / http://10.240.0.3:2369/
ErrorLog #########
CustomLog ######### common
SSLEngine on
SSLCertificateFile ############
SSLCertificateKeyFile ########
</VirtualHost>
关于具有别名和代理匹配的 Apache,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52918962/