掲示板

Portal instances not resolving to www (SOLVED)

9年前 に gordon daniels によって更新されました。

Portal instances not resolving to www (SOLVED)

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
I've been testing the portal instance feature in 6.1.2ga3. My DNS setup has the cname www.domainname.com, but when I type in the www.domainname.com it goes to the first site www.test.com. I've tried editing the portal instance page to include www but the site still resolves to primary.

Also, I am running apache as proxy for tomcat. Anyone have any suggestions?

thanks
thumbnail
9年前 に David H Nebinger によって更新されました。

RE: Portal instances not resolving to www

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
gordon daniels:
Also, I am running apache as proxy for tomcat. Anyone have any suggestions?


I wonder if this is the issue...

Can you try hitting www.domainname.com:8080 and see if you get the right results directly from tomcat? That would help to isolate apache as the possible issue...

I think with apache/mod jk it may not be passing it all directly through; I know especially sometimes you'll have issues w/ the remote ip in the http request on the tomcat side in that it appears to come from the apache system rather than the remote client system sometimes.
thumbnail
9年前 に Olaf Kock によって更新されました。

RE: Portal instances not resolving to www

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
Adding to this: If you're using http for the proxy connection (not jk) you might need to add "ProxyPreserveHost On" to your proxy configuration in Apache. This way tomcat has a chance to see the hostname that has been used to connect to Apache, otherwise it will only see the name that you've configured in Apache for the proxy forwarding - potentially an IP address.

My recommendation is to always use mod_jk or mod_proxy_jk instead of the http version, as this will transparently forward all available headers and you don't need to configure more.
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
Olaf: Here is my config using mod_jk:

<VirtualHost *:80>
ServerAdmin admin@test.com
ServerName test.com
ServerAlias www.test.com
RewriteEngine On

<Directory />
Options FollowSymlinks
AllowOverride None
</Directory>

ProxyPass /webmail !
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/


</VirtualHost>

Am I doing something wrong here? Would it be possible to see an example of how you configure it?

thanks
thumbnail
9年前 に David H Nebinger によって更新されました。

RE: Portal instances not resolving to www

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Ah, that explains it!

You only have one virtual host defined for www.test.com, the same one that you're getting through mod jk. So apache is getting the www.domainname.com (only cuz the dns resolves there) and inferring the user meant www.test.com.

You need a second virtual host record for www.domainname.com configured in the same way as www.test.com. That will allow apache to intercept both correctly and feed through mod jk correctly.

Check out the httpd example: http://httpd.apache.org/docs/2.2/vhosts/examples.html Version may not match what you're using, but you should get the gist...
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
David: thank you! I had considered that but the documentation for mod_jk is confusing. I've looked at a lot of examples and every one of them is very different. This really helps.

thanks again
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
David: This is frustrating. I have each site resolving to www.sitesname.com. , but now if you just type in the site name without www it goes to the main site. Any suggestions on how to make this work? :-(

thanks
thumbnail
9年前 に David H Nebinger によって更新されました。

RE: Portal instances not resolving to www

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Do you have your ServerAlias records defined? If ServerName is www.sitesname.com, ServerAlias should just be sitesname.com.
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
David: thanks for the fast response! I have it exactly reversed. Will try your suggestion.

thanks again
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
David: Well I tried that but the same result. Test.com (main site) - if I type in www.domainsitename.com it goes to that site. If I type in domainsitename.com it goes to test.com.

Sorry to bug you with this. I was hoping for an easy fix :-) Will keep trying.

thanks again
thumbnail
9年前 に Jack Bakker によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
I have ended up in (adopting?) a pattern of separating, in apache conf files, redirect configs from main configs. Below requires mod_jk .. and in Liferay the virtualhost only needs to reference the ultimate target being www.withwww.com

-- withoutwww.com.conf (redirect config) --

<virtualhost *:80>
    ServerAdmin importantperson@mydomain.com
    ServerName withoutwww.com
    RedirectMatch /(.*) http://www.withwww.com/$1
    RedirectPermanent / http://www.withwww.com
</virtualhost>


-- www.withwww.com.conf (main config) ---

<virtualhost *:80>
   ServerAdmin importantperson@mydomain.com
   ServerName www.withwww.com:80
   DocumentRoot /opt/withwww
   SetEnvIfNoCase Request_URI ^/robots.txt$ no-jk
   JkMount /* worker1
</virtualhost>

<virtualhost *ip*:443>
   ServerAdmin importantperson@mydomain.com
   ServerName www.withwww.com:80
   DocumentRoot /opt/withwww
   SSLEngine On
   SSLCertificateKeyFile /etc/apache2/ssl.key/www.withwww.com.key
   SSLCertificateFile /etc/apache2/ssl.crt/www.withwww.com.crt
   SSLCertificateChainFile /etc/apache2/ssl.crt/intermediate.crt
   JkMount /* worker1
</virtualhost>


======
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
Jack: Long time no hear! Well, you have a couple of things different in your directives. I will give them a try. I've tried just about everything else :-)

thanks for the reply
thumbnail
9年前 に Jack Bakker によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
Hey Gordon

My configs above are dependent on a mod_jk install into apache2 and relevant config of a workers.properties

a simple one is this:

worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=1
worker.worker1.connect_timeout=20000
worker.worker1.prepost_timeout=20000
worker.worker1.socket_keepalive=True
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
Jack: well that did not work either :-( Thank you for sharing. You can see my config up above. If anything jumps out at you let me know.

thanks again
thumbnail
9年前 に Jack Bakker によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
Your config uses proxy, mine is different, uses mod_jk
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
Jack: thank you for your help! I use mod_jk and was using a config that I read on a hosting site. So, I am making changes now.

thanks again
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
Jack: Getting closer. Now sites go to :80 but not to liferay. So will continue to massage.

thanks
thumbnail
9年前 に Krzysztof Gołębiowski によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 549 参加年月日: 11/06/25 最新の投稿
Hello Everybody,
I used to have this problem some time ago, and at first I created single VirtualHost entry for each domain. That drove me crazy for few days until I came back and wrote this generic Virtual Host configuration:

<virtualhost *:80>
    ServerAdmin me@mydomain.com
    ServerName *

    LogLevel warn
    ErrorLog /var/log/httpd/all-error.log
    CustomLog /var/log/httpd/all-access.log hostnames

    ProxyRequests Off

    <proxy *>
        Order deny,allow
        Allow from all
    </proxy>

    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / ajp://localhost:8009/
</virtualhost>

I think the magic part is: ServerName *

It looks simle but works emoticon It proxies several domains, and Liferay knows itself which Site the request should go to.

Of course you need to put NameVirtualHost *:80 at the beginning of your Apache config and load appropriate modules.

Regards,
KG
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
Krzysztof: Thanks for sharing. Will give it a try.

thanks again
thumbnail
9年前 に Jack Bakker によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
I much prefer apache mod_jk instead of just proxy to a port

the no-jk is very useful for serving static through apache direct and not even needing liferay/tomcat in back, a simple example:

SetEnvIfNoCase Request_URI ^/robots.txt$ no-jk

there are also additional workers.properties configs that are useful and one workers.properties can reference different workers thus pointing to different liferays in back listening at different ports 8009 8010 etc.
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
Jack: I agree. At one time I had mod_jk configured correctly and it worked like a dream. Wish I had a copy of that config :-( .

I'm working on it. It will happen.

thanks for all your comments. Although I suspect you are just trying to catch up with David on postings :-)
thumbnail
9年前 に David H Nebinger によって更新されました。

RE: Portal instances not resolving to www

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Although I suspect you are just trying to catch up with David on postings :-)


ROTFL
thumbnail
9年前 に Jack Bakker によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
David H Nebinger:
Although I suspect you are just trying to catch up with David on postings :-)


ROTFL


The theme to "Mission Impossible" comes to mind... emoticon
thumbnail
9年前 に Olaf Kock によって更新されました。

RE: Portal instances not resolving to www

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
Jack Bakker:
I much prefer apache mod_jk instead of just proxy to a port

the no-jk is very useful for serving static through apache direct...


There's also the JkUnMount directive - took me a while to learn about that one. Totally works as advertised.
thumbnail
9年前 に David H Nebinger によって更新されました。

RE: Portal instances not resolving to www

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
I know the blog I did covered apache httpd and tomcat using mod_jk. Didn't do anything with multiples, but it did have the JkUnmounts in place...
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
David: I've read that blog along time ago and it definitely will work for one vhost. I have it all working now.

thank you again for all your help.
thumbnail
9年前 に Jack Bakker によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
Olaf Kock:

There's also the JkUnMount directive...


cool, haven't tried JkUnMount tho likely will stumble into it to maybe experience the difference from no-jk

Thanks
thumbnail
9年前 に Jack Bakker によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 978 参加年月日: 10/01/03 最新の投稿
gordon daniels:
Now sites go to :80 but not to liferay.


not enough info to go on to sleuth

your mod_jk is not configured properly ?
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
Jack: All is working now. Your examples did not work for me. Maybe it has to do with that I use Slackware. Anyway, I did figure it out and now all sites can be accessed with www or not.

Thank you for all your help. It helped me to solve the issue.
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
David: thanks for the reply. I tried that but it goes to main site. But I think that the mod_jk is the issue.

thanks again.
9年前 に gordon daniels によって更新されました。

RE: Portal instances not resolving to www

Liferay Master 投稿: 797 参加年月日: 08/08/24 最新の投稿
Olaf: thank you for replying. I am using mod_jk. I will give your suggestion a try.

thanks