你可以通常在你的tomcat安裝前使用Apache。設置一個重定向代理規則到你的tomcat。如果這不起作用,apache會發送一個「503服務暫時不可用」,您可以將其配置爲您的維護頁面。
的Apache應用程序文件看起來有點像這個
<VirtualHost *>
ServerName example.com
ServerAlias *.example.com
ServerAdmin [email protected]
RewriteEngine on
RewriteRule ^/static/(.*) /some/path/for/static/files/static/$1 [L]
RewriteRule ^(.*) http://127.0.0.1:8080$1 [P]
ErrorLog /var/log/apache2/example/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/example/access.log combined
ServerSignature On
ErrorDocument 503 /static/site_down.html
</VirtualHost>
第一重寫規則變化低於一定的URI從這些靜態文件直接提供無代理的所有文件(/靜態/)到一個目錄。你也可以使用它來爲你的網站提供所有的靜態資源,這可以彌補在你的tomcat前面有一個apache的一般(小)性能損失。
ErrorDocument指令更改位於此靜態路徑中的文檔site_down.html的普通503響應。
對於這個工作,你需要啓用了mod_rewrite和mod_proxy的/ mod_proxy_http和 啓用代理在您的Apache2配置
<Proxy *>
Order Deny,Allow
Deny from all
Allow from all
</Proxy>