
Apache 리버스 프록시에 오류가 있습니다. 현재 저는 4개의 웹사이트에 역방향 프록시를 수행하고 있습니다.
- 1.1.1.1/a
- 1.1.1.2/b
- 1.1.1.3/c
- 1.1.1.4/일
a 및 b 웹 사이트에 대한 역방향 프록시를 수행할 때 문제가 없습니다. 이미지도 좋고 문제 없습니다.
그러나 c 및 d 웹 사이트의 경우. 이미지가 로드되지 않습니다. 내 access_log에 로그가 있습니다.
- - [08/May/2014:10:40:36 +0800] "GET /whatshot_v3/images/promo/img_samplePromo.jpg HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/menu/faq_butt_03.png HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/banner/text_planprice.gif HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/banner/text_services.gif HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/banner/text_account.gif HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/shortcut/bann_store.gif HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/shortcut/bann_rewards.gif HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/shortcut/bann_idd.gif HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/footer/img_customerService.png HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/footer/icon_fb.png HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/footer/icon_tw.png HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/footer/icon_rss.png HTTP/1.1" 404 1245
- - [08/May/2014:10:40:36 +0800] "GET /images_v3/footer/icon_share.png HTTP/1.1" 404 1245
Apache 역방향 프록시 서버 자체에서 액세스하는 데에는 문제가 없습니다. 외부에서 접속시 문제가 발생합니다.
다른 컴퓨터에서 URL을 직접 입력해 보았는데 이미지가 로드되었습니다.
1.1.1.1 - - [08/May/2014:10:19:00 +0800] "GET **/d/images_v3/footer/icon_share.png** HTTP/1.1" 200 869 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
1.1.1.1 - - [08/May/2014:10:18:24 +0800] "GET **/images_v3/footer/icon_share.png HTTP/1.1" 404 1245** "htt://1.2.3.4/digi/landing.do" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36"
보시다시피 첫 번째 링크가 작동 중입니다. 두 번째 것은 그렇지 않습니다.
정상적으로 웹페이지를 요청하면 두 번째 링크를 요청하게 되고 경로를 찾을 수 없어 404 오류가 발생합니다.
첫 번째 링크를 직접 입력하면 이미지가 발견됩니다.
링크를 입력하면 c, d 웹사이트가 리디렉션되는 것을 확인했습니다. 이것이 문제의 원인입니다.
1.1.1.3/c --> 1.1.1.3/c/index_other.html
1.1.1.4/d --> 1.1.1.4/d/landing.do
내 Apache 역방향 프록시 구성은 다음과 같습니다.
<VirtualHost *:80>
#ServerAdmin [email protected]
#DocumentRoot /www/docs/dummy-host.example.com
#ServerName dummy-host.example.com
ErrorLog logs/arp_error_log
CustomLog logs/arp_access_log common
ProxyRequests Off
<Location /a>
ProxyPass http://1.1.1.1/a
ProxyPassReverse http://1.1.1.1/a
</Location>
<Location /b>
ProxyPass http://1.1.1.2/b
ProxyPassReverse http://1.1.1.2/b
</Location>
<Location /c>
ProxyPass http://1.1.1.3/index_other.html
ProxyPassReverse http://1.1.1.3/index_other.html
</Location>
<Location /d>
ProxyPass http://1.1.1.4:8080
ProxyPassReverse http://1.1.1.4:8080
</Location>
</VirtualHost>
그렇다면 이 문제를 어떻게 해결하나요? 나는 mod_rewrite 및 mod_proxy_html을 연구해 왔지만 문제를 해결하는 데 행운이 없습니다.
답변1
이미지에 대해 별도의 위치 컨테이너를 사용할 수 있습니다.
나는 이것을 테스트하고 있지 않지만 어느 정도는 되어야 합니다.
/c의 경우:
<Location /c/images_v3>
ProxyPass http://1.1.1.3/images_v3
ProxyPassReverse http://1.1.1.3/images_v3
</Location>
<Location /c>
ProxyPass http://1.1.1.3/index_other.html
ProxyPassReverse http://1.1.1.3/index_other.html
</Location>
/d의 경우 무슨 일이 일어나고 있는지 잘 모르겠습니다. 1.1.1.4:8080에 모든 것을 /landing.do로 리디렉션하는 리디렉션이 있을 수 있나요? 이 경우 다음은 도움이 되지 않습니다.
<Location /d/images_v3>
ProxyPass http://1.1.1.4:8080/images_v3
ProxyPassReverse http://1.1.1.4:8080/images_v3
</Location>
<Location /d>
ProxyPass http://1.1.1.4:8080
ProxyPassReverse http://1.1.1.4:8080
</Location>