2017-09-27 144 views
0

下面是使用 「的ProxyPass」 和 「ProxyPassReverse」Apache代理從HTTPS重定向到HTTP

Listen 1.2.3.4:80 
<VirtualHost 1.2.3.4:80> 
    ProxyPreserveHost On 
    SSLProxyEngine On 
    ProxyPass /artifactory https://xxxx.xxxx.xxx/artifactory 
    ProxyPassReverse /artifactory https://xxxx.xxxx.xxx/artifactory 

Listen 1.2.3.4:443 
<VirtualHost 1.2.3.4:443> 
    SSLProxyEngine On 
    ProxyPreserveHost On 
    ProxyPass /artifactory https://xxxx.xxxx.xxx/artifactory 
    ProxyPassReverse /artifactory https://xxxx.xxxx.xxx/artifactory 
</VirtualHost> 

當我運行下面wget命令,以某種方式將其重定向apache的反向代理配置片段到http:

#wget --no-check-certificate "https://xxxx.xxxx.xxx/artifactory/" 
--2017-09-27 06:25:50-- 
https://xxxx.xxxx.xxx/artifactory/ 
Resolving xxxx.xxxx.xxx... 1.2.3.4 
Connecting to xxxx.xxxx.xxx|1.2.3.4|:443... connected. 
WARNING: certificate common name 「xxxx.xxxx.xxx」 doesn't match requested 
host name 「xxxx.xxxx.xxx」. 
HTTP request sent, awaiting response... 302 Found 
Location: http://xxxx.xxxx.xxx/artifactory/webapp/ [following] 
--2017-09-27 06:25:51-- 
http://xxxx.xxxx.xxx/artifactory/webapp/ 
Connecting to xxxx.xxxx.xxx|1.2.3.4|:80... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: 1449 (1.4K) [text/html] 
Saving to: 「index.html.18」 

如果我運行 「/ artifactory的/ web應用/#/家」 它https使用wget命令:

wget --no-check-certificate "https://xxxx.xxxx.xxx/artifactory/webapp/#/home" 
--2017-09-27 06:12:48- 
https://xxxx.xxxx.xxx/artifactory/webapp/ 
Resolving xxxx.xxxx.xxx... 1.2.3.4 
Connecting to xxxx.xxxx.xxx|1.2.3.4|:443... connected. 
WARNING: certificate common name 「xxxx.xxxx.xxx」 doesn't 
match requested host name 「xxxx.xxxx.xxx」. 
HTTP request sent, awaiting response... 200 OK 
Length: 1449 (1.4K) [text/html] 
Saving to: 「index.html.17」 

2017-09-27 06:12:49 (73.1 MB/s) - 「index.html.17」 saved [1449/1449] 

我沒有在代理配置文件的任何位置定義重定向。

任何人都可以提出這種行爲背後的原因。以及如何避免將其重定向到HTTP。

回答

0

看來你已經配置了你的反向代理來監聽以'/ artifactory'結尾的網址。 考慮增加以下內容:

RewriteRule ^/$      /artifactory/webapp/ [R,L] 
RewriteRule ^/artifactory(/)?$  /artifactory/webapp/ [R,L] 
RewriteRule ^/artifactory/webapp$ /artifactory/webapp/ [R,L] 

此外,您使用Artifactory的OSS或Pro?如果Pro沒有選擇直接從Artifactory生成Apache配置代碼片段。

+0

謝謝阿里爾。這個重寫規則是否需要添加到這兩個部分(80和443)..?而且由於這個apache也被其他服務所使用,將首先重寫線路影響在80/443節中定義的其他服務。我有Artifactory的企業版。我不能使用snippet生成的代理配置,因爲太多的服務依賴於這個apache代理,我不想通過添加snippet生成的配置來打破/影響其他服務。運行apache 2.2的代理是不按原樣添加snippet配置的另一個原因。 2.2可能不支持某些參數。 – Pushpraj