[opencms-dev] [Solved] RE: Request for assistance with OpenCms and Apache configuration on Tomcat

Ramon Gavira Sáenz ramon.gavira at sagasoluciones.com
Fri Apr 14 15:08:19 CEST 2023


I finally found out the solution:

Here is the solution for an installation on webapps/opencms2


<VirtualHost *:443>

    ServerName domain.example.com

    ServerAlias domain.alias.example.com



    ServerAdmin webmaster@ domain.example.com <mailto:webmaster at sagasoluciones.com>



    # 1. Use the webapp's home as document root

    DocumentRoot /var/lib/tomcat9/webapps/opencms2



    # 2. Allow Apache to access the export and resources folders directly

    <Directory /var/lib/tomcat9/webapps/opencms2/export>

        Options FollowSymlinks

        Order Deny,Allow

        Allow from all

        Satisfy any

    </Directory>



    <Directory /var/lib/tomcat9/webapps/opencms2/resources>

        Options FollowSymlinks

        Order Deny,Allow

        Allow from all

        Satisfy any

    </Directory>



    # 3. Set logging behavior (optional)

      ErrorLog /var/log/apache2/opencms2.error.log

      CustomLog /var/log/apache2/opencms2.access.log combined

      LogLevel trace3





    # SSL Certificates

    SSLCertificateFile /etc/letsencrypt/live/cert/cert.pem

    SSLCertificateKeyFile /etc/letsencrypt/live/cert/privkey.pem

    Include /etc/letsencrypt/options-ssl-apache.conf

    SSLCertificateChainFile /etc/letsencrypt/live/cert/chain.pem





    # 4. Enable rewriting

    RewriteEngine On

    ProxyPreserveHost On







    # 5. (Optional) Deny access to PHP files

    RewriteCond %{REQUEST_FILENAME} (.+)\.php(.*)

    RewriteRule (.*) / [F]





    # 6. Add opencms/ prefix if required

    RewriteCond %{REQUEST_URI} !^/opencms2/workplace.*$

    RewriteCond %{REQUEST_URI} !^/opencms2/VAADIN/.*$

    RewriteCond %{REQUEST_URI} !^/opencms2/resources/.*$

    RewriteCond %{REQUEST_URI} !^/export/.*$

    RewriteCond %{REQUEST_URI} !^/opencms2/webdav.*$

    RewriteRule !^/opencms2/opencms/(.*)$ /opencms2/opencms%{REQUEST_URI} [PT]



    # 7. Rewrite rule to make OpenCms' static export working

    RewriteCond %{REQUEST_URI} ^/export/.*$

    RewriteCond "%{DOCUMENT_ROOT}%{REQUEST_FILENAME}" !-f

    RewriteCond "%{DOCUMENT_ROOT}%{REQUEST_FILENAME}/index_export.html" !-f

    RewriteRule .* /handle404?exporturi=%{REQUEST_URI}&%{QUERY_STRING} [PT]





    # 8. Connect to Tomcat using proxy_ajp

    ProxyPass /handle404  ajp://localhost:8009/opencms2/handle404

    ProxyPass /opencms2/opencms ajp://localhost:8009/opencms2/opencms

    ProxyPass /opencms2/webdav(.*) ajp://localhost:8009/opencms2/webdav$1

    ProxyPass /opencms2/VAADIN ajp://localhost:8009/opencms2/VAADIN

    ProxyPass /opencms2/workplace ajp://localhost:8009/opencms2/workplace





</VirtualHost>



De: opencms-dev <opencms-dev-bounces at opencms.org> En nombre de Ramon Gavira Sáenz via opencms-dev
Enviado el: miércoles, 12 de abril de 2023 11:53
Para: opencms-dev at opencms.org
CC: Ramon Gavira Sáenz <ramon.gavira at sagasoluciones.com>
Asunto: [opencms-dev] Request for assistance with OpenCms and Apache configuration on Tomcat

I am in need of assistance with configuring two instances of OpenCms on the same Tomcat server, using Apache as the web server. The Apache proxy configuration described in the OpenCms Documentation Site (Apache proxy configuration (opencms.org)<https://documentation.opencms.org/opencms-documentation/server-administration/apache-proxy-configuration/index.html>) assumes that OpenCms is installed as the ROOT application in Tomcat.

Has anyone had experience configuring a proxy for an OpenCms installation that is not the ROOT application, using Proxy AJP to remove the /opencms/opencms/ context path?

This task is driving me crazy and any help would be greatly appreciated.

Best regards,

Ramón Gavira Sáenz

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opencms.org/pipermail/opencms-dev/attachments/20230414/8e692a5f/attachment.htm>


More information about the opencms-dev mailing list