Thanks to OTN
I actually had the same problem: I have one oracle instance (11gXE2) with Glassfish and the APEX Listener. I’m hosting different applications (in different workspaces) on this instance. The whole configuration is accessible by one fixed IP adres from the internet. I further have several domains (and sub-domains) mapped to this one IP. To ensure that a request for http://www.d1.com is routed to Application1 and http://www.d2.com to Application2 I wrote a smal plsql-“proxy (or multiplexer) using the OWA_UTIL.get_cgi_env (‘HOST’) variable to determine the requested domain and then redirect to an application that belongs to it.
The configuration I have stored in a table, for matching I use LIKE patterns:
Table for my “proxy”:
CREATE TABLE "PROXY_RULES" ( "ID" NUMBER, "SEQ" NUMBER, "HOST_PATTERN" VARCHAR2(1000), "REDIR_URL" VARCHAR2(1000), CONSTRAINT "PROXY_RULES_PK" PRIMARY KEY ("ID") ENABLE ) ;
filling for your example:
ID SEQ HOST_PATTERN REDIR_URL -- --- ------------ --------------------------------------- 1 5 %.d1.com http://www.d1.com/apex/f?p=App1:Home:0 3 10 %.d2.com http://www.d1.com/apex/f?p=App2 2 15 %.d3.com http://www.d1.com/apex/f?p=App3:1:0 ... 0 99 % http://www.d1.com/apex/f?p=App1:Home:0
and the actual procedure to redirect calls:
PROCEDURE redirect IS t_host varchar2 (250); t_redir varchar2 (250); BEGIN t_host := OWA_UTIL.get_cgi_env ('host'); SELECT redir_url INTO t_redir FROM (SELECT redir_url FROM proxy_rules WHERE UPPER (t_host) LIKE UPPER (host_pattern) ORDER BY seq, id) WHERE ROWNUM < 2; OWA_UTIL.redirect_url (curl => t_redir, bclose_header => TRUE); EXCEPTION WHEN OTHERS THEN OWA_UTIL.redirect_url (curl => 'http://www.d1.com', bclose_header => TRUE); END redirect;
Grant execute on this procedure to the APEX_PUBLIC_USER, create a public synonym on it and
make sure all requests without a path get redirected to it, for example with a simple index.html containing a redirect to “/apex/redirect”:
<meta http-equiv=”refresh” content=”0; url=/apex/redirect”>
This works fine, but doesn’t check that App2 is accessed through http://www.d1.com. I still have to add this functionality.
I hope this helps.
You can use WebLogic as a web server, but unlike Apache where you place a html file to the www directory and you can see it immediately, in WebLogic you have to deploy it to a domain.
1. The html file must be in a directory of your choice (i.e. C:testhtml).
2. On that directory create a WEB-INF directory (from the example of step 1 it would be C:testhtmlWEB-INF).
3. In the WEB-INF directory create a file called web.xml with the following content:
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE web-app PUBLIC
“-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”
4. Login to the WebLogic Console to deploy the application:
5. Click on Deployments.
6. Click Install and set the path to the directory of step 3 (if the directory only contains the html file and the WEB-INF subdirectory you will see no files to select, but the Next button will be enabled anyway).
7. Leave default “Install this deployment as an application” and click Next.
8. Select the servers you wish to deploy this.
9. Accept the defaults and click Finish.
10. Activate Changes if the message appears.
11. You should now be able to see the application started in the deployments screen.
12. You can now access your static content on the WebLogic Server port via the following URL:
<web-app xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns=”http://java.sun.com/xml/ns/javaee” xmlns:web=”http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd” xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd” id=”WebApp_ID” version=”2.5″>