Fórumok

How to serve theme static content from Apache?

brian bohnet, módosítva 12 év-val korábban

How to serve theme static content from Apache?

Junior Member Bejegyzések: 46 Csatlakozás dátuma: 2010.01.27. Legújabb bejegyzések
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
brian bohnet, módosítva 12 év-val korábban

RE: How to serve theme static content from Apache?

Junior Member Bejegyzések: 46 Csatlakozás dátuma: 2010.01.27. Legújabb bejegyzések
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
David H Nebinger, módosítva 12 év-val korábban

RE: How to serve theme static content from Apache?

Liferay Legend Bejegyzések: 14919 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
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.
brian bohnet, módosítva 12 év-val korábban

RE: How to serve theme static content from Apache?

Junior Member Bejegyzések: 46 Csatlakozás dátuma: 2010.01.27. Legújabb bejegyzések
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
Yogesh Sapkal, módosítva 9 év-val korábban

RE: How to serve theme static content from Apache?

New Member Bejegyzések: 6 Csatlakozás dátuma: 2014.01.23. Legújabb bejegyzések
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
Juan Gonzalez P, módosítva 12 év-val korábban

RE: How to serve theme static content from Apache?

Liferay Legend Bejegyzések: 3089 Csatlakozás dátuma: 2008.10.28. Legújabb bejegyzések
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
Thomas Berg, módosítva 10 év-val korábban

RE: How to serve theme static content from Apache?

Regular Member Bejegyzések: 131 Csatlakozás dátuma: 2009.09.07. Legújabb bejegyzések
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
Juan Gonzalez, módosítva 10 év-val korábban

RE: How to serve theme static content from Apache?

Liferay Legend Bejegyzések: 3089 Csatlakozás dátuma: 2008.10.28. Legújabb bejegyzések
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.