如何配置apache服务器以允许wget与代理?

时间:2016-03-17 18:07:19

标签: apache proxy wget httpd.conf

我是apache httpd的新手

我将主机 ServerHost1 设置为httpd

的文件服务器
# httpd -v
Server version: Apache/2.4.6 (Red Hat Enterprise Linux)
Server built:   Dec  2 2014 08:09:42

我已将文件TestFile.txt放在/var/www/html/TestDir/TestFile.txt

我修改了httpd.conf的一部分,如下所示

<Directory />
    Order deny,allow
    Allow from all
</Directory>

在具有完全互联网访问权限的测试主机 TestHost1 上,我可以使用wget下载我的文件

TestHost1]# wget http://ServerHost1/TestDir/TestFile.txt
--2016-03-17 13:39:12--  http://ServerHost1/TestDir/TestFile.txt
Resolving ServerHost1 (ServerHost1)... <IP address>
Connecting to ServerHost1 (ServerHost1)|<IP address>|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2859976598 (2.7G) [application/octet-stream]
Saving to: ‘TestFile.txt’

2% [>                                                            ] 60,645,376  24.0MB/s 

在坐在半隔离网络 TestHost2 上的主机上,我必须使用代理才能使用wget。它适用于谷歌

TestHost2]# wget google.ca
--2016-03-17 13:53:26--  http://google.ca/
Resolving proxy.com (proxy.com)... <ProxyIP>
Connecting to proxy.com (proxy.com)|<ProxyIP>|:3128... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: http://www.google.ca/ [following]
--2016-03-17 13:53:26--  http://www.google.ca/
Reusing existing connection to proxy.com:3128.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

    [ <=>                                   ] 19,928      --.-K/s   in 0.1s

2016-03-17 13:53:27 (159 KB/s) - ‘index.html’ saved [19928]

但是,当我尝试从ServerHost1获取文件时,它会收到ERROR 503:服务不可用

TestHost2]# wget http://ServerHost1/TestDir/TestFile.txt
--2016-03-17 13:57:13--  http://ServerHost1/TestDir/TestFile.txt
Resolving proxy.com (proxy.com)...<ProxyIP>
Connecting to proxy.com (proxy.com)|<ProxyIP>|:3128... connected.
Proxy request sent, awaiting response... 503 Service Unavailable
2016-03-17 13:57:13 ERROR 503: Service Unavailable.

所以问题是

(1)当文件显然可用时,为什么我看到503 ServiceUnavailable(因为我可以从testhost1下载)?

(2)如何配置我的httpd.conf文件,以便TestHost2可以从ServerHost1中获取文件?

1 个答案:

答案 0 :(得分:1)

如Apache文档https://httpd.apache.org/docs/2.4/mod/mod_proxy.html

中所述,可以尝试使用ProxyRequests