Fórum

Need to change web.server.host property during runtime

Venkata G, modificado 11 Anos atrás.

Need to change web.server.host property during runtime

New Member Postagens: 20 Data de Entrada: 29/01/11 Postagens Recentes
Guys, Please help me in below problem

I have single liferay instance and it has single site on it. This single site is serving multiple clients and they access the site using their dedicated domain name

xxx.mysite.com -> domain name for the client xxx
yyy.mysite.com -> domain name for the client yyy

These domain names are configured in apache web server which is sitting infront of liferay instance. I used property in portal-ext.properties web.server.host to configure the webserver information in liferay. Liferay uses this property to generate all the links on the page(if this property is not mentioned it uses the servername to generate the urls). But using this I can only define one site at a time. I can not achieve above functionality. I went to the liferay code and in PortalImpl.java it has following code



public String getPortalURL(
		String serverName, int serverPort, boolean secure) {

		StringBundler sb = new StringBundler();

		if (secure || Http.HTTPS.equals(PropsValues.WEB_SERVER_PROTOCOL)) {
			sb.append(Http.HTTPS_WITH_SLASH);
		}
		else {
			sb.append(Http.HTTP_WITH_SLASH);
		}

		if (Validator.isNull(PropsValues.WEB_SERVER_HOST)) {
			sb.append(serverName);
		}
		else {
			sb.append(PropsValues.WEB_SERVER_HOST);
		}

		if (!secure) {
			if (PropsValues.WEB_SERVER_HTTP_PORT == -1) {
				if ((serverPort != Http.HTTP_PORT) &&
					(serverPort != Http.HTTPS_PORT)) {

					sb.append(StringPool.COLON);
					sb.append(serverPort);
				}
			}
			else {
				if (PropsValues.WEB_SERVER_HTTP_PORT != Http.HTTP_PORT) {
					sb.append(StringPool.COLON);
					sb.append(PropsValues.WEB_SERVER_HTTP_PORT);
				}
			}
		}

		if (secure) {
			if (PropsValues.WEB_SERVER_HTTPS_PORT == -1) {
				if ((serverPort != Http.HTTP_PORT) &&
					(serverPort != Http.HTTPS_PORT)) {

					sb.append(StringPool.COLON);
					sb.append(serverPort);
				}
			}
			else {
				if (PropsValues.WEB_SERVER_HTTPS_PORT != Http.HTTPS_PORT) {
					sb.append(StringPool.COLON);
					sb.append(PropsValues.WEB_SERVER_HTTPS_PORT);
				}
			}
		}

		return sb.toString();
	}




In above method it uses the web.server.host property defined in poratal-ext.properties and constructs the URLs. Now I need to overwrite this method to determine the web server host during runtime.

my question are.
How to overwrite this function in PoralImpl.java? Do I need use extension to achieve this?
Is anyother way(betterway) to achieve this functionality.

I am using liferay 6.1.0 GA-1/tomcat bundle
Manish Kharkar, modificado 7 Anos atrás.

RE: Need to change web.server.host property during runtime

New Member Postagens: 24 Data de Entrada: 08/12/14 Postagens Recentes
Hello Venkata,
Were you able to find a solution to this? We have a similar requirement. Liferay version 6.1.2

Hello All,
Is this configuration possible in later versions of Liferay if not in 6.1?
Regards,
Manish.
Manish Kharkar, modificado 7 Anos atrás.

RE: Need to change web.server.host property during runtime

New Member Postagens: 24 Data de Entrada: 08/12/14 Postagens Recentes
Hello,
So a similar situation as one mentioned by Venkata.
We have 2 instances of tc-server pointing to a single portal meta database.
Each of them have a single site - businessSite - same content.
We have configured 2 public urls in httpd one for each instance. portal.domain.com and client2.portal.domain.com
We have placed the portal-ext.properties for the instances in the WEB-INF/classes folder.
For the first instance we have configured the web.server.host to portal.domain.com and for the second to client2.portal.domain.com
This way using a single site, 2 Liferay instances and 2 public urls we are able to serve 2 clients.
Can above configuration be done with a single Liferay instance instead of 2?
Can the web.server.host value be picked up from the url?

Regards,
Manish.
thumbnail
Juan Gonzalez, modificado 7 Anos atrás.

RE: Need to change web.server.host property during runtime

Liferay Legend Postagens: 3089 Data de Entrada: 28/10/08 Postagens Recentes
Hi Manish.

Manish Kharkar:
Hello,
So a similar situation as one mentioned by Venkata.
We have 2 instances of tc-server pointing to a single portal meta database.
Each of them have a single site - businessSite - same content.
We have configured 2 public urls in httpd one for each instance. portal.domain.com and client2.portal.domain.com
We have placed the portal-ext.properties for the instances in the WEB-INF/classes folder.
For the first instance we have configured the web.server.host to portal.domain.com and for the second to client2.portal.domain.com
This way using a single site, 2 Liferay instances and 2 public urls we are able to serve 2 clients.
Can above configuration be done with a single Liferay instance instead of 2?
Can the web.server.host value be picked up from the url?

Regards,
Manish.


So you have two different Liferay WAR pointing to the same database and different portal-ext.properties? That's absolutely not recommended.

If you have two different URL, that means you're going to access different pages/contents. That's why your approach of having two URL for same content doesn't make sense.

That's why Liferay supports different virtualhost, but using different sites.

If you want to share content you can do that by adding content in Global scope and then use it in each of your sites, but in the end you will have different sites. You can make usage of children sites too, and having common content in a parent site. Additionally you can use same site/layout templates if you want your sites to look the same and reuse structure.
thumbnail
Juan Gonzalez, modificado 7 Anos atrás.

RE: Need to change web.server.host property during runtime

Liferay Legend Postagens: 3089 Data de Entrada: 28/10/08 Postagens Recentes
Hi Venkata.

Venkata G:

I have single liferay instance and it has single site on it. This single site is serving multiple clients and they access the site using their dedicated domain name

xxx.mysite.com -> domain name for the client xxx
yyy.mysite.com -> domain name for the client yyy


Does xxx.mysite.com and yyy.mysite.com have same content or you have to show different content for each client?