cancel
Showing results for 
Search instead for 
Did you mean: 

Apache + Alfresco Proxy

dough
Champ in-the-making
Champ in-the-making
I have found several close solutions on these forums and through google, but nothing that exactly matches my desired results.  Here is what I am hoping to configure.

I want to be able to have the users access Alfresco Explorer and Alfresco Share like the following:

http://alfresco.somedomain.com
http://share.somedomain.com

I have attempt to use Apache configurations exclusively, but these only resulted in the following valid URL

http://www.somedomain.com/alfresco  OR  http://alfresco.somedomain.com/alfresco

I would prefer not to have the user add the "/alfresco" subdirectory OR "/share" subdirectory.

Here is the Apache virtual host configure I used.

<VirtualHost *:80>
ServerName alfresco.somedomain.com
ProxyRequests On
ProxyPreserveHost On
ProxyPass / http://www.somedomain.com:8080/alfresco
ProxyPassReverse / http://www.somedomain.com:8080/alfresco
ProxyPass /share http://www.somedomain.com:8080/share
ProxyPassReverse /share http://www.somedomain.com:8080/share
</VirtualHost>

This works, but it requires the user to type in the ServerName plus the subdirectory (i.e. http://www.somedomain.com/alfresco).  I want the user to only be required to remember http://alfresco.somedomain.com

I also attempt the following solution, which is a combination of Tomcat proxy configuration with AJP and Apache virtual host configuration.  I found this solution here http://forums.alfresco.com/en/viewtopic.php?f=9&t=13254

Add to /opt/alfresco/tomcat/conf/server.xml

<Service name="Catalina">

    <!– Define an AJP 1.3 Connector on port 8009 –>
    <Connector port="8009"
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

  </Service>

Apache configuration

<VirtualHost *:80>
ServerName alfresco.somedomain.com
ProxyRequests On
RewriteEngine On
RewriteLogLevel 3
RewriteLog "/var/log/httpd/rewrite.log"
RewriteRule ^/(.*) ajp://127.0.0.1:8009/alfresco$1 [P,L]
</VirtualHost>

However this solutions shows a blank page with the URL being rewritten to http://alfresco.somedomain.com/alfresco/.  If I change the Apache RewriteRule to this:

RewriteRule ^/alfresco(.*) ajp://127.0.0.1:8009/alfresco$1 [P,L]

Then the following URL works http://alfresco.somedomain.com/alfresco.  But once again, I would prefer that the user only need to type in http://alfresco.somedomain.com

Any assistance would be appreciated.

Doug
8 REPLIES 8

gronfelt
Champ in-the-making
Champ in-the-making
If you just want your users to able to access Alfresco and Share on alfresco.somedomain.com and share.somedomain.com respectively you could just use mod_rewrite, like this:

<VirtualHost *:80>
ServerName alfresco.somedomain.com
RewriteEngine On
RewriteLogLevel 3
RewriteLog "/var/log/httpd/rewrite.log"
RewriteRule ^/(.*) http://alfresco-server:8080/alfresco$1
</VirtualHost>

There's no need for proxypass and no need to use the AJP connector. However, this solution will expose the real URL (http://alfresco-server:8080/alfresco in my example) once the redirect is done, so you might want to put Alfresco behind another proxy (using mod_jk or ProxyPass) and then rewrite to that, if you don't want to expose the alfresco server directly to the users and don't wan't to show the port 8080 in the url. That proxy could be another virtualhost on the same Apache server.

oblivian
Champ in-the-making
Champ in-the-making
Just a note: I don't think you should have ProxyRequests On. If I am not mistaken (I might be) that is for forward proxying. This makes your server vulnerable to abuse if you haven't closed down what IP's that can use it as proxy. If you are using apache just for reversed proxying you should set to: ProxyRequests Off.

BTW, can't you just mount /share as suggested and you use the RedirectPermanent directive, so the user simply types http://www.domain.tld and apache automatically redirects to: http://www.domain.tld/share/page/site-index

Regards,

Oblivian

dough
Champ in-the-making
Champ in-the-making
Hi gronfelt,

You have gotten me closer to my desired results.  I do want to hide the URL from the user.  I kind of understand what you have mentioned about using another proxy, but I am not sure how to make this happen?  Can you please provide an example of both the mod_jk way and ProxyPass way of providing this proxy that would allow for hiding the true URL?  I have never been fond of allowing end-users to see the :8080 in the URL.

P.S. I also wanted to thank oblivian for his response.

Thanks for the assistance.
Doug

gronfelt
Champ in-the-making
Champ in-the-making
A simple solution (but I'm not sure it fits your requirements) would be to put Tomcat behind a proxy using mod_jk and then let Apache redirect the subdomains alfresco and share to that common proxy. It would then look like this:

1. A user enters share.somedomain.com
2. Apache catches the url share.somedomain.com with a virtual host and rewrites the url to http://www.somedomain.com/share (for instance, www could be something else)
3. Apache catches the url http://www.somedomain.com with another virtual host and uses mod_jk to send the request to Tomcat.

(The same procedure would go for alfresco.somedomain.com)

What the user will see is the url http://www.somedomain.com/share or http://www.somedomain.com/alfresco. I don't know if that's ok? I guess you could set up a solution where the user would see share.somedomain.com/share, but that would need more complicated rewrite rules.

The best way to set up the proxy is probably with mod_jk. The basic setup of mod_jk is described here:

http://tomcat.apache.org/connectors-doc/generic_howto/quick.html

What it does not describe is that you need to make some modifications to tomcat/conf/server.xml, you should uncomment this part:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


Basically you should end up with something like:

<VirtualHost *:80>
ServerName alfresco.somedomain.com
RewriteEngine On
RewriteLogLevel 3
RewriteLog "/var/log/httpd/rewrite.log"
RewriteRule ^/ http://www.somedomain.com/alfresco
</VirtualHost>

<VirtualHost *:80>
ServerName share.somedomain.com
RewriteEngine On
RewriteLogLevel 3
RewriteLog "/var/log/httpd/rewrite.log"
RewriteRule ^/ http://www.somedomain.com/share
</VirtualHost>

<VirtualHost *:80>
ServerName www.somedomain.com
JkMount /* worker1
</VirtualHost>

gronfelt
Champ in-the-making
Champ in-the-making
I gave it a second thought, and it's actually not difficult at all to configure it to work without redirecting to the third subdomain (http://www.somedomain.com).

You could use two virtual hosts looking like this:

<VirtualHost *:80>
ServerName share.somedomain.com
RewriteEngine On
RewriteLogLevel 3
RewriteLog "/var/log/httpd/rewrite.log"
RewriteCond %{REQUEST_URI} !^/share/
RewriteRule ^/. http://share.somedomain.com/share/ [R]
JkMount /share/* worker1
</VirtualHost>

<VirtualHost *:80>
ServerName alfresco.somedomain.com
RewriteEngine On
RewriteLogLevel 3
RewriteLog "/var/log/httpd/rewrite.log"
RewriteCond %{REQUEST_URI} !^/alfresco/
RewriteRule ^/. http://alfresco.somedomain.com/alfresco/ [R]
JkMount /alfresco/* worker1
</VirtualHost>
That way, any url:s beginning with share.somedomain.com will be redirected to share.somedomain.com/share and the same for alfresco.somedomain.com, I hope that's good enough.

dough
Champ in-the-making
Champ in-the-making
Hi gronfelt,

I have gotten side tracked, but hopefully I will have time later tonight to try your recommendations.  I appreciate you sharing your insight and knowledge.

I will let you (and others that read the forum) know the results of my attempt.

Thanks,
Doug

renata
Champ in-the-making
Champ in-the-making
Hello gronfelt,

I need a lot your collaboration, because until now, after a lot of search in Internet, I can't resolve the issue related to follow your instructions to put Alfresco behind apache.

I'm using:

Debian 5
Apache2
alfresco-community-3.4.d-installer-linux-x32.bin

I followed exactly that you are suggesting, without include Directoryroot and Document root (the system is using the default: /var/www) and when I go to the share.somedomain.com the browser display only the folder and files in the default directory (ftp style). Alfresco is running ok, without any problem when I'm using sharedomain.com:8080/share (or /alfresco)

I'm sure that exist some syntax or missing arguments in my virtualhost configuration, but I can't discover what is exactly and in the Internet I'm not founding something so clear like your solution, by this reason, I would like your collaboration.

Thanks in advance, I'll appreciate any comments.

Renata

bensewell
Champ in-the-making
Champ in-the-making
managed to get the mod_jk working with the suggestions from gronfelt.  But if i enable both virtual hosts at the same time the user is diverted to the first rule which is the /share page.  It does port them from port 80 on Apache to 8080/share on tomcat.  What i'm interested in doing is hiding the port number to the end user as suggested by using another virtual server acting as a proxy.  I'm a bit new to editing Apache so getting  a bit confused.

I'm trying to get everthing working locally at the moment by adding the rules to the internal server's IP address then once i'm happy with everything i'll edit these rules to work with our network / re-configure for use out on the DMZ.