Message Boards

CSS, JS and other static contents are not loading with Apache load balancer

Maulik Shah, modified 7 Years ago.

CSS, JS and other static contents are not loading with Apache load balancer

New Member Posts: 4 Join Date: 8/22/16 Recent Posts
Hi All,

I am using Liferay 7.0 GA3 version and using Apache 2.4 as reverse proxy. Both servers installed on Windows 2012 R2 and facing problem while loading home page for liferay where all JS, CSS and other static components are not getting displayed and getting HTTP 500 error instead.

Apache config - (load balancing two Liferay servers running on two different VMs)

httpd.conf -

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so

RewriteEngine On

#forces everything under /web/guest/signup to secure if non-secure (https)
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ https://%{SERVER_NAME}:443$1 [R,L]

ProxyRequests Off

<Location / >
ProxyPass balancer://mybalancer stickysession=JSESSIONID
ProxyPassReverse "balancer://mybalancer" stickysession=JSESSIONID
</Location>

<Proxy balancer://mybalancer>
BalancerMember ajp://my.server.com:8009/ route=s1
BalancerMember ajp://my.server2.com:8009/ route=s2
</Proxy>

httpd-ssl.conf -

<VirtualHost _default_:443>
SSLEngine on
ServerName my.server.com:443
SSLCertificateFile "${SRVROOT}/conf/ssl/lr-stage-server.crt"
SSLCertificateKeyFile "${SRVROOT}/conf/ssl/lr-stage-server.key"
DocumentRoot "${SRVROOT}/htdocs"
# DocumentRoot access handled globally in httpd.conf
CustomLog "${SRVROOT}/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
<Directory "${SRVROOT}/htdocs">
Options Indexes Includes FollowSymLinks
AllowOverride AuthConfig Limit FileInfo
Require all granted
</Directory>
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
</virtualhost>

Have changed tomcat server.xml on both the servers -

<Engine name="Catalina" defaultHost="localhost" jvmRoute="s1"> and
<Engine name="Catalina" defaultHost="localhost" jvmRoute="s2">

I am getting below errors on browser -

Failed to load resource: the server responded with a status of 500 (Internal Server Error)
https://my.server.com/combo?browserId=other&minifierType=&theme…duct_menu_web_portlet_ProductMenuPortlet:%2Fcss%2Fmain.css&t=1478912808000 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
https://my.server.com/o/classic-theme/css/main.css?browserId=ot…Id=classic_WAR_classictheme&minifierType=css&languageId=en_US&b=7002&t=195 Failed to load resource: the server responded with a status of 500 (Internal Server Error)
(index):11 Uncaught TypeError: Cannot set property 'list' of undefined
at (index):11
https://my.server.com/combo?browserId=other&minifierType=css&la…igation-control-menu-theme-contributor/product_navigation_control_menu.css Failed to load resource: the server responded with a status of 500 (Internal Server Error)
https://my.server.com/image/layout_set_logo?img_id=44936&t=1483591866720 Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Apache error logs -

[Wed Jan 04 23:15:15.954935 2017] [proxy:warn] [pid 5320:tid 1060] [client 10.99.59.8:61057] AH01144: No protocol handler was valid for the URL /o/classic-theme/css/main.css. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule., referer: https://my.server.com/
[Wed Jan 04 23:15:16.270960 2017] [proxy:warn] [pid 5320:tid 1064] [client 10.99.59.8:61062] AH01144: No protocol handler was valid for the URL /image/layout_set_logo. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule., referer: https://my.server.com/

If I try to access one of the failed Apache URL directly to another browser window, I am getting HTTP 500 error with following Respnse headers -

Request URL:https://my.server.com/o/mentions-web/css/mentions.css

Response Headers

Connection:close
Content-Length:530
Content-Type:text/html; charset=iso-8859-1
Date:Thu, 05 Jan 2017 05:20:15 GMT
Server:Apache/2.4.23 (Win64) OpenSSL/1.0.2h
Strict-Transport-Security:max-age=63072000; includeSubDomains

If I try the same URL that connects to Tomcat instead (so bypassig Apache), then I am getting HTTP 200 with following response headers -

Request URL:http://my.server.com:8080/o/mentions-web/css/mentions.css

Response Headers

Cache-Control:max-age=315360000, public
Content-Encoding:gzip
Content-Length:195
Content-Type:text/css
Date:Thu, 05 Jan 2017 05:20:52 GMT
ETag:"d187c5"
Server:Apache-Coyote/1.1
Set-Cookie:JSESSIONID=C41D0DA1E582219136FBBC8D8466F2F4.s1; Path=/; HttpOnly
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
X-XSS-Protection:1

one thing to note is if I remove load balance config and try to connect one apache instance to one liferay server then everything is working fine.

ProxyPass / ajp://my.server.com:8009/
ProxyPassReverse / ajp://my.server.com:8009/

So looks like some configuration issue at apache side? Please help.
Maulik Shah, modified 7 Years ago.

RE: CSS, JS and other static contents are not loading with Apache LB

New Member Posts: 4 Join Date: 8/22/16 Recent Posts
Could anyone please let me know how to resolve this problem?
thumbnail
David H Nebinger, modified 7 Years ago.

RE: CSS, JS and other static contents are not loading with Apache load bala

Liferay Legend Posts: 14914 Join Date: 9/2/06 Recent Posts
No, this isn't the apache forums, it's the Liferay forums. Your issue is not Liferay related, it's your misconfiguration of the apache tomcat pair that is leading to your 500's.
Maulik Shah, modified 7 Years ago.

RE: CSS, JS and other static contents are not loading with Apache load bala

New Member Posts: 4 Join Date: 8/22/16 Recent Posts
Thanks David. I understand that but I have found lots of blogs on web.liferay site related to Apache an hence thought if someone can help who had setup Apache as load balancer before for Liferay.
thumbnail
David H Nebinger, modified 7 Years ago.

RE: CSS, JS and other static contents are not loading with Apache load bala

Liferay Legend Posts: 14914 Join Date: 9/2/06 Recent Posts
The thing is, you're going to find a lot more help from a tomcat site than you will the Liferay site. Here you'll only find anecdotal cases where someone got httpd+tomcat to work; on the tomcat site, you're going to find a heck of a lot more folks who have done that a heck of a lot more.

In the end you're looking at a config issue between apache and tomcat for your environment is causing the problem; it won't be Liferay related. My suggestion to head over there is only meant to point you at the folks who will truly be able to help you get it squared away.