Tendo o Liferay instalado (versão 6.0.6) numa máquina e o Apache HTTP Server (versão 2.0) noutra máquina diferente a servir de Reverse Proxy, são necessários alguns passos para disponibilizar o Liferay em HTTPS.
No restante texto explica-se como fazer esta configuração em Solaris 10.
1. Criar um certificado auto-assinado
Instruções detalhadas em http://www.akadia.com/services/ssh_test_certificate.html
1.1 Gerar uma RSA Private Key
Numa shell Solaris:
# /usr/sfw/bin/openssl
Introduzir o comando:
genrsa -des3 -out liferay.key 2048
Escolher uma pass phrase.
Irá gerar o ficheiro
liferay.key.
1.2 Gerar um Certificate Signing Request
Numa shell Solaris:
#/usr/sfw/bin/openssl
Introduzir o comando:
req -new -key liferay.key -out liferay.csr
Introduzir a pass phrase escolhida para a chave privada (RSA Private Key).
Introduzir informação nos campos seguintes (exemplo):
Country Name (2 letter code) [US]:PT
State or Province Name (full name) [Some-State]:Lisboa
Locality Name (eg, city) []:Lisboa
Organization Name (eg, company) [Unconfigured OpenSSL Installation]:CFB
Organizational Unit Name (eg, section) []:FUTEBOL
Common Name (eg, YOUR name) []:LIFERAY
Email Address []:
--
A challenge password []:
An optional company name []:
Irá gerar o ficheiro
liferay.csr.
1.3 Remoção da pass phrase da chave
Criar uma cópia da chave
liferay.key e renomeá-la para
liferay.key.futebol
De seguida executar numa shell Solaris:
#/usr/sfw/bin/openssl
Introduzir o comando:
rsa -in liferay.key.futebol -out liferay.key
Introduzir a pass phrase escolhida para a chave privada (RSA Private Key).
1.4 Gerar um certificado auto-assinado
Numa shell Solaris:
#/usr/sfw/bin/openssl
Introduzir o comando:
x509 -req -days 3650 -in liferay.csr -signkey liferay.key -out liferay.crt
Irá gerar o ficheiro
liferay.crt.
2. Copiar a chave e o certificado para o Apache
De seguida executar numa shell Solaris:
# mkdir /etc/apache2/ssl.crt
# mkdir /etc/apache2/ssl.key
# cp liferay.crt /etc/apache2/ssl.crt/ssl.crt
# cp liferay.key /etc/apache2/ssl.key/ssl.key
3. Configurar SSL no Apache
No ficheiro
/etc/apache2/ssl.conf
Comentar:
#SSLRandomSeed startup builtin
#SSLRandomSeed connect builtin
Descomentar:
SSLRandomSeed startup file:/dev/urandom 512
SSLRandomSeed connect file:/dev/urandom 512
Alterar
SSLCertificateFile /etc/apache2/ssl.crt/server.crt
para
SSLCertificateFile /etc/apache2/ssl.crt/ssl.crt
Alterar
SSLCertificateKeyFile /etc/apache2/ssl.key/server.key
para
SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/ssl.key
Alterar
<VirtualHost _default_:443>
para
<VirtualHost *:443>
4. Activar o SSL no Solaris
Verificar se o SSL está activo
Nnuma shell Solaris
:
# svcprop -p httpd/ssl svc:network/http:apache2
Se
false:
# svccfg -s http:apache2 setprop httpd/ssl=true
# svcadm refresh http:apache2
# svcprop -p httpd/ssl svc:network/http:apache2
Deverá agora dar
true.
5. Restart Apache
Testar
https://apache.reverse.proxy
Onde
apache.reverse.proxy é o endereço da máquina onde está instalado o Apache.
6. Configuração do Reverse Proxy no Apache
No ficheiro http.conf ou noutro que seja incluído:
<Location / >
ProxyPass http://liferay.location:8080/
ProxyPassReverse http://liferay.location:8080/
<
Location />
Onde
liferay.location é o endereço da máquina onde está instalado o Liferay.
Restart ao Apache
7.
Configuração do Reverse Proxy no Liferay
Editar o ficheiro
~/liferay-portal-6.0.6/tomcat-6.0.29/webapps/ROOT/WEB-INF/classes/portal-ext.properties
Acrescentar:
web.server.http.port=80
web.server.host=apache.reverse.proxy
web.server.https.port=443
web.server.protocol=https
redirect.url.security.mode=ip
redirect.url.domains.allowed=
redirect.url.ips.allowed=127.0.0.1,LIFERAY_IP_MACHINE,APACHE_REVERSE_PROXY_IP_MACHINE
# Para não criar o esquema de demonstração
schema.run.enabled=true
schema.run.minimal=false
Restart ao Liferay.
Testar.
http://apache.reverse.proxy
Deverá abrir a página do Liferay.
8. Configuração do Reverse Proxy com SSL no Apache
<Location / >
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
ProxyPass http://liferay.location:8080/
ProxyPassReverse http://liferay.location:8080/
<
Location />
Restart ao Apache.
Testar.
https://apache.reverse.proxy
Deverá aparecer a página do Liferay em HTTPS.
Escrevendo
http://apache.reverse.proxy dever-se-á ser redireccionado para
https://apache.reverse.proxy