Senthil Murugan's Blog

Home » Apex » One IP for Multiple Domains in Apex

One IP for Multiple Domains in Apex

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’m using the method on my sites rokit.nl, www.fifapex.net, m.fifapex.net, www.themes4apex.com and www.themes4apex.nl. Try it!

I hope this helps.

Regards,
Christian Rokitta

==========================================

https://forums.oracle.com/forums/thread.jspa?threadID=2249504&tstart=180

Hi JeanParis,

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”
http://java.sun.com/j2ee/dtds/web-app_2_3.dtd”&gt;
<web-app>
</web-app>

4. Login to the WebLogic Console to deploy the application:
i.e: http://myserver.com:7001/console

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:
http://myserver.com:7001/testhtml/[your_html_file]

Thanks,
Cris

=======================================================

http://weblogicserveradministration.blogspot.in/2010/10/how-to-make-application-deployed-in.html

OPTION-2)
If you don’t want to change your “weblogic.xml” then Please login to admin console—
Servers—>YourManagedServerName(Click)—>Protocol (Tab)—>Http (Sub Tab)—>Default WebApp Context Root:

NOTE: In the above Field Please specify your WebApplications Context Root Preceding by forward slash (Example: /MyContextRoot)…so that after Server restart that Application will become your Servers Default WebApp….
For better results .. Please add the “welcome-page” inside your “web.xml” like following:
<?xml version=”1.0″ encoding=”UTF-8″?>
<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″>
<display-name>SpringOne</display-name>
<welcome-file-list>
<welcome-file>YourWelcomePage.jsp</welcome-file>
</welcome-file-list>
</web-app>
===============================================================

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: