我正在尝试设置一个基本的虚拟主机,将所有对 test.local 的请求代理到我在 127.0.0.1:8080 上运行的 WEBrick 服务器,同时将所有对 localhost 的请求保留到 /var/www 中的静态文件。我正在运行 Ubuntu 10.04。
我安装了 libapache2-mod-proxy-html,并启用了 a2enmod 代理模块。我还启用了虚拟主机。但是,每当我访问 test.local 时,我总是会收到一个神秘的 500 服务器错误,并且我的所有日志都告诉我:
[Thu Mar 03 01:43:10 2011] [warn] proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
这是我的虚拟主机:
<VirtualHost test.local:80>
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
ServerAdmin webmaster@localhost
ServerName test.local
ProxyPreserveHost On
# prevents this folder from being proxied
ProxyPass /static !
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
以下是我对 mod_proxy 的设置:
<IfModule mod_proxy.c>
#turning ProxyRequests on and allowing proxying from all may allow
#spammers to use your proxy to send email.
ProxyRequests Off
<Proxy *>
# default settings
#AddDefaultCharset off
#Order deny,allow
#Deny from all
##Allow from .example.com
AddDefaultCharset off
Order allow,deny
Allow from all
</Proxy>
# Enable/disable the handling of HTTP/1.1 "Via:" headers.
# ("Full" adds the server version; "Block" removes all outgoing Via: headers)
# Set to one of: Off | On | Full | Block
ProxyVia On
</IfModule>
有人知道我做错了什么吗?谢谢
答案1
看起来您没有加载mod_proxy_http
模块(这是代理 HTTP 服务器所需的)。我面前没有 Ubuntu 10.04,但我记得它类似于:
sudo a2enmod proxy_http
答案2
上述答案对我没有帮助,因为我收到的错误与所选答案中作者的评论相同。不过,我确实找到了以下帖子和更改,解决了我的问题:
sudo /usr/sbin/setsebool -P httpd_can_network_connect 1
来源:http://allscm.com/archives/apache2-proxy-disabled-connection-on-localhost.html