There are multiple articles on the web about how to configure Oracle Apex 4 on Oracle 10g XE and Apache2. The basic setup that is you use the Apache2 as a Proxy to serve the Oracle EPG Gateway pages, compressing text with mod_deflate, setting expiry headers for images with mod_expires and restricting access to APEX administration using mod_rewrite.
I have run through them and tried many configuarations but I always got an error when I was quickly switching between tabs. The most annoying factor was that the error seemed to appear randomly and there was no record of it in the Apache log or the Oracle log files. The error is as follows
0 HTTP/1.1 200 OK Server: Oracle XML DB/Oracle Database Content-Type: text/html; charset=UTF-8 X-DB-Content-length: 46439 Transfer-Encoding: chunked
The configuration I have come up with, combining various solutions proposed in Oracle Forums and blog posts is (I have removed site specific details, but you get the general idea).
#proxypassing SetEnv force-proxy-request-1.0 1 SetEnv proxy-nokeepalive 1 ProxyRequests Off ProxyPreserveHost OffOrder deny,allow Allow from all ProxyPass /i http://example.com:8080/i ProxyPassReverse /i http://example.com:8080/i ProxyPass / http://example.com:8080/ ProxyPassReverse / http://example.com:8080/
Of course, you would have to change the url in ProxyPass to match your server and port settings.
#url rewriting RewriteEngine On RewriteRule ^/$ apex/f?p=200:101 [R=301] # Look for requests using the GET request method RewriteCond %{REQUEST_METHOD} GET # Look for requests to /apex/f RewriteCond %{REQUEST_URI} /apex/f.* # Allow access if the app is 200 RewriteCond %{QUERY_STRING} !^p=200.* # Comment the following to restrict access to Apex Login Application #RewriteCond %{QUERY_STRING} !^p=4550.* # Comment the following to restrict access to Apex Administration Console #RewriteCond %{QUERY_STRING} !^p=4500.* # Comment the following to restrict access to Apex data load/unload #RewriteCond %{QUERY_STRING} !^p=4300.* # Comment the following to restrict access to Apex Application Builder #RewriteCond %{QUERY_STRING} !^p=4000.* RewriteCond %{QUERY_STRING} !^p=BUILDER.* # If the above rules do not match, deny access RewriteRule /.* [F]
In the above code, you must replace 200 with the APEX application id that your application is using.
#compression DeflateCompressionLevel 9 SetOutputFilter DEFLATE BrowserMatch ^Mozilla/4\.0[678] no-gzip\ BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html # Don't compress images SetEnvIfNoCase Request_URI \ \.(?:gif|jpe?g|png)$ no-gzip dont-vary AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE text/x-component
And finally, header expiry.
#mod_expires ExpiresActive On ExpiresDefault "access" ExpiresByType image/gif "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/bmp "access plus 1 month" ExpiresByType image/png "access plus 1 month" Alias /i/ "/usr/lib/oracle/xe/apex/images/" <Directory "/usr/lib/oracle/xe/apex/images/"> AllowOverride None Order allow,deny Allow from all ExpiresActive On ExpiresDefault "access plus 1 month" AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE text/x-component
Make sure that the path to APEX images matches your installation (here I am using Ubuntu Linux).