掲示板

How to serve theme static content from Apache?

11年前 に brian bohnet によって更新されました。

How to serve theme static content from Apache?

Junior Member 投稿: 46 参加年月日: 10/01/27 最新の投稿
We use an Apache host, which routes requests to a reverse-proxy, which then connects to Tomcat/Liferay over ajp. When using themes, we see 60% of the traffic routed back to Liferay is for static content, like .css, .js and img's. How easy is it to pull the static content out of a custom theme and have the main Apache serve it? How do we over-ride the theme mechanics which set all the url's for all this content? Anyone else done this?

Thanks
Brian
11年前 に brian bohnet によって更新されました。

RE: How to serve theme static content from Apache?

Junior Member 投稿: 46 参加年月日: 10/01/27 最新の投稿
I found the solution with some more digging. By reading the .dtd for liferay-look-and-feel.xml it explains:

For example, suppose your theme is deployed to the servlet path "/test-theme"
and your theme image-path is "/xyz/images". By default, the portal will return
"/test-theme/xyz/images" for the path of the theme's images. You can override it
by setting virtual-path to "/virtual" and have the portal return
"/virtual/xyz/images". This is useful when you want all static files to be
served by Apache for better performance.
thumbnail
11年前 に David H Nebinger によって更新されました。

RE: How to serve theme static content from Apache?

Liferay Legend 投稿: 14914 参加年月日: 06/09/02 最新の投稿
For us we deploy to tomcat as well as to the apache htdocs folder following the same path in both places (so a file /html/themes/classic/styles.css is the same path for both servers). Duplication of files certainly, but it is easier to manage. The cleanest way, of course, would be to do the tomcat deployment then only copy the static files over to the apache side (you can't just do a shared mapping to tomcat's webapps folder since it uses ROOT for the root instance but everything else wouldn't).

Then we use JkUnmount statements in the workers property file so the static files are not pushed through to tomcat for handling.

The /virtual thing mentioned I believe is used when you don't have your Liferay/Tomcat as the root on the apache side, although I haven't had to use it myself.
11年前 に brian bohnet によって更新されました。

RE: How to serve theme static content from Apache?

Junior Member 投稿: 46 参加年月日: 10/01/27 最新の投稿
Thanks for the reply. Looks like I'll be going into Apache/Reverse-proxy setup to handle this. Because we deployed at ROOT in Tomcat and are using the portal.proxy.path property, all paths I modify in the liferay-look-and-feel.xml are being appended to the portal.proxy.path value, hence I get all 404's.

portal.proxy.path=/liferay_epc/ptl/secure

<virtual-path>/xusers/igen254/theme</virtual-path>
or
<css-path>/xusers/igen254/theme/css</css-path>
<images-path>/xusers/igen254/theme/images</images-path>
<javascript-path>/xusers/igen254/theme/js</javascript-path>

all end up like this:

/liferay_epc/ptl/secure/ricola-myup-theme/xusers/igen254/theme/images/portlet

I'd rather not have to modify the Apache rules every time a new theme comes around, so maybe I can wild card it to redirect only static files (css,js,images) with *-theme in the path.
thumbnail
9年前 に Yogesh Sapkal によって更新されました。

RE: How to serve theme static content from Apache?

New Member 投稿: 6 参加年月日: 14/01/23 最新の投稿
brian bohnet:
Thanks for the reply. Looks like I'll be going into Apache/Reverse-proxy setup to handle this. Because we deployed at ROOT in Tomcat and are using the portal.proxy.path property, all paths I modify in the liferay-look-and-feel.xml are being appended to the portal.proxy.path value, hence I get all 404's.

portal.proxy.path=/liferay_epc/ptl/secure

<virtual-path>/xusers/igen254/theme</virtual-path>
or
<css-path>/xusers/igen254/theme/css</css-path>
<images-path>/xusers/igen254/theme/images</images-path>
<javascript-path>/xusers/igen254/theme/js</javascript-path>

all end up like this:

/liferay_epc/ptl/secure/ricola-myup-theme/xusers/igen254/theme/images/portlet

I'd rather not have to modify the Apache rules every time a new theme comes around, so maybe I can wild card it to redirect only static files (css,js,images) with *-theme in the path.



Its work for me.
If you are using theme(xyz-theme)

file name--> liferay-look-and-feel.xml
Write like →
<theme id="xyz" name="xyz-theme" >
<virtual-path>http://static.example.com/xyz-theme/</virtual-path>
</theme>
thumbnail
11年前 に Juan Gonzalez P によって更新されました。

RE: How to serve theme static content from Apache?

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
The easiest way I've found to do this is having haproxy + varnish for cache the files we want.

Haproxy will get the content on Tomcat or Varnish depending on some conditions (for example, URL ends with.. etc).
thumbnail
10年前 に Thomas Berg によって更新されました。

RE: How to serve theme static content from Apache?

Regular Member 投稿: 131 参加年月日: 09/09/07 最新の投稿
Hi Juan,

I believe many would like to know how you've setup HAProxy + Varnish with Liferay to speed things up!
If you can find the the time, please make a Wiki or a Blogpost on this

Thanks

Regards Thomas
thumbnail
10年前 に Juan Gonzalez によって更新されました。

RE: How to serve theme static content from Apache?

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
Thomas Berg:
Hi Juan,

I believe many would like to know how you've setup HAProxy + Varnish with Liferay to speed things up!
If you can find the the time, please make a Wiki or a Blogpost on this

Thanks

Regards Thomas


Hi Thomas,

good idea! Will try to implement that architecture and document it in Wiki when Symposiums are over.

Thanks.