Apache-2.2
Apache ProxyPass 缺少圖像
我有一個 apache 伺服器,它位於我的 glassfish 伺服器前面。mydomain.com 直接轉到我在 apache 上的靜態文件,而不是如果您點擊子域 forum.mydomain.com,它會轉到 glassfish webapp forum/ 的 127.0.0.1:8080/forum/。這個代理似乎工作它把我帶到網路應用程序,但所有的圖像都不見了!這是我進行虛擬主機設置的方法。
NameVirtualHost *:80 <VirtualHost *:80> ServerName www.mydomain.com ServerAlias subdomain.mydomain.com mydomain.com DocumentRoot "/usr/local/apache/htdocs" </VirtualHost> <VirtualHost *:80> ServerName forum.mydomain.com # any logging config, etc, that you need ProxyPass / http://127.0.0.1:8080/forum/ ProxyPassReverse / http://127.0.0.1:8080/forum/ </VirtualHost>
在訪問日誌中,這就是我所看到的。
[15/Jan/2012:03:28:02 +0000] "GET /forums/list.page HTTP/1.1" 200 12861 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/logo.jpg HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/styles/style.css?1326582403934 HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/icon_mini_recentTopics.gif HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/icon_mini_search.gif HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/icon_mini_members.gif HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/styles/en_US.css?1326582403934 HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/icon_mini_groups.gif HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/folder_big.gif HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/icon_mini_login.gif HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/whosonline.gif HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/icon_mini_register.gif HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/ping_session.jsp HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/folder_lock.gif HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/folder.gif HTTP/1.1" 404 1075 [15/Jan/2012:03:28:02 +0000] "GET /forum/templates/default/images/folder_new.gif HTTP/1.1" 404 1075
任何想法為什麼圖像不起作用?
論壇的程式碼在
/forum/
發送給客戶端的 HTML 中硬編碼了路徑,或者在其配置中的某個地方定義了路徑。如果您可以將其更改為/
,請這樣做;否則,您可以在 Apache 配置中解決它:<VirtualHost *:80> ServerName forum.mydomain.com ProxyPass /forum/ http://127.0.0.1:8080/forum/ ProxyPassReverse /forum/ http://127.0.0.1:8080/forum/ ProxyPass / http://127.0.0.1:8080/forum/ ProxyPassReverse / http://127.0.0.1:8080/forum/ </VirtualHost>
您可以通過將重寫引擎放置在虛擬主機中來修復它。
RewriteEngine on RewriteRule ^/forum/(images|javascripts|stylesheets)(.*) /forum/$1$2
有關更多詳細資訊,請參閱此處以獲取重寫引擎