如何配置 apache 服务器以允许 wget 使用代理?
How to configure apache server to allow wget with proxy?
我对 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>
在具有完全 Internet 访问权限的测试主机 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 工作。它适用于 google
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 获取我的文件时,出现错误 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 获取文件?
也许可以尝试使用 ProxyRequests
,如 Apache 文档 https://httpd.apache.org/docs/2.4/mod/mod_proxy.html
中所述
我对 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>
在具有完全 Internet 访问权限的测试主机 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 工作。它适用于 google
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 获取我的文件时,出现错误 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 获取文件?
也许可以尝试使用 ProxyRequests
,如 Apache 文档 https://httpd.apache.org/docs/2.4/mod/mod_proxy.html