You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Gareth <ga...@gmail.com> on 2011/07/29 22:47:23 UTC

Assigning Wars To Ports And Subdirectories?

Hello,

I am not sure whether this is a PAX Web question, or a Karaf question but:

(1) If I install a war/wab file, is there any way of making it available on
certain ports? For example, I would probably want the Karaf console and
Active MQ console on a separate port to my application wabs/wars (as my
wabs/wars may be visible through a firewall whilst Karaf console should not
be).

(2) Any way of installing wars (which are not OSGi wabs) to subdirectories?
In tomcat I could do this by adding a "#" as part of the war name (e.g.
hosting#fred.war could be accessed by http://hostname/hosting/fred.war).
There isn't a similar feature in Karaf/PAX Web, is there?

thanks in advance,
Gareth

--
View this message in context: http://karaf.922171.n3.nabble.com/Assigning-Wars-To-Ports-And-Subdirectories-tp3210710p3210710.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Assigning Wars To Ports And Subdirectories?

Posted by Achim Nierbeck <bc...@googlemail.com>.
HI Gareth,

yeah the reverse Proxy is a great functionality and I use this
Architectural design quite often. Makes your applications much more
safe :-)

Regards, Achim

2011/8/2 Gareth <ga...@gmail.com>:
> Hello Achim,
>
> The virtual hosts feature is probably exactly what I need.
>
> As you suggested, for now I will use Apache as a reverse proxy to hide those
> services I don't want to make publicly available.
>
> thanks,
> Gareth
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Assigning-Wars-To-Ports-And-Subdirectories-tp3210710p3219163.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 
--
*Achim Nierbeck*


Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
Committer & Project Lead
blog <http://notizblog.nierbeck.de/>

Re: Assigning Wars To Ports And Subdirectories?

Posted by Gareth <ga...@gmail.com>.
Hello Achim,

The virtual hosts feature is probably exactly what I need.

As you suggested, for now I will use Apache as a reverse proxy to hide those
services I don't want to make publicly available.

thanks,
Gareth



--
View this message in context: http://karaf.922171.n3.nabble.com/Assigning-Wars-To-Ports-And-Subdirectories-tp3210710p3219163.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Assigning Wars To Ports And Subdirectories?

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi Gareth,

to me this seems like a similar requirement as a "virtual-host" setting.
I'm planning on supporting jetty-web.xml in the next release of Pax Web.

till that is available I just suggest to use different context paths and
put a Apache Webserver
in front of the Karaf server for providing these services.

regards, Achim

Am 30.07.2011 07:26, schrieb Gareth:
> Hello JB,
>
> I didn't realize I could do this for non-wab wars:
>
>> install
>> webbundle:file:./MyWebApp.war?Bundle-SymbolicName=com.mycompany.mywebapp&Web-ContextPath=/hosting/com.mycompany.mywebapp&<additional
>> custom parameters defined by me>
> ...so I guess that helps part of my problem.
>
> I still hope to find a way to restrict specific web applications to certain
> ports though...
>
> Thanks again.
>
> regards,
> Gareth
>
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Assigning-Wars-To-Ports-And-Subdirectories-tp3210710p3211252.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


-- 
-----

Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>  Committer & Project Lead


Re: Assigning Wars To Ports And Subdirectories?

Posted by Gareth <ga...@gmail.com>.
Hello JB,

I didn't realize I could do this for non-wab wars:

> install
> webbundle:file:./MyWebApp.war?Bundle-SymbolicName=com.mycompany.mywebapp&Web-ContextPath=/hosting/com.mycompany.mywebapp&<additional
> custom parameters defined by me>

...so I guess that helps part of my problem.

I still hope to find a way to restrict specific web applications to certain
ports though...

Thanks again.

regards,
Gareth






--
View this message in context: http://karaf.922171.n3.nabble.com/Assigning-Wars-To-Ports-And-Subdirectories-tp3210710p3211252.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Assigning Wars To Ports And Subdirectories?

Posted by Gareth <ga...@gmail.com>.
Hello JB,

I knew about the Web-ContextPath in the MANIFEST.MF. I was just hoping there
was a way to be able to do this without making all wars into wabs :). For
these wars, could I perhaps create my own bundle listener, make it run
before Pax Web (is that possible?) and go add the Web-ContextPath into the
MANIFEST.MF before PAX Web reads it (is that possible?)?

I also gave your two suggestions a try:

(1) With the first suggestion, I got more ports configured for Jetty, but
all my wars were still available on all ports.

(2) I added the file install configuration (I see now two file install
configurations in the Karaf console). I can now add files from the new
location...though web applications are still installed in the same dir.

There is no way to run multiple Pax Web instances in the same Karaf
instance, is there (with the ability to explicitly assign each war to a
specific instance?)?

Thank you very much for the help.

regards,
Gareth

--
View this message in context: http://karaf.922171.n3.nabble.com/Assigning-Wars-To-Ports-And-Subdirectories-tp3210710p3211059.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Assigning Wars To Ports And Subdirectories?

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Gareth,

1/ currently, Pax Web support the webapp context path using the 
following OSGi statements:

   <Web-ContextPath>/myapp</Web-ContextPath>
   <Webapp-Context>/myapp</Webapp-Context>

When you install the HTTP feature, it installs a jetty.xml file in the 
etc folder.
In this jetty.xml file, you can define several port number for the 
embedded jetty server.

Create a new Connector in the jetty.xml with an ID, like:

<Call name="addConnector">
   <Arg>
     <New id="my" 
class="org.eclipse.jetty.server.nio.SelectChannelConnector">
       ...
       <Set name="port">5340491</Set>
       ...
     </New>
   </Arg>
</Call>

After, to associate the webapp with the Configured server, try to create 
a etc/context.xml file containing:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
   <Set name="contextPath">/myapp</Set>
   <Set name="connectorNames">
     <Array type="String">
       <Item>my</Item>
     </Array>
   </Set>
</Configure>

Without guarantee, I never tried this before :)

2/ for the directory, you can create a new file in etc, for instance 
etc/org.apache.felix.fileinstall-war.cfg containing:

felix.fileinstall.dir=${karaf.base}/war
felix.fileinstall.tmpdir=${karaf.data}/webapp
felix.fileinstall.poll=1000

Could you try this ?

Regards
JB

On 07/29/2011 10:47 PM, Gareth wrote:
> Hello,
>
> I am not sure whether this is a PAX Web question, or a Karaf question but:
>
> (1) If I install a war/wab file, is there any way of making it available on
> certain ports? For example, I would probably want the Karaf console and
> Active MQ console on a separate port to my application wabs/wars (as my
> wabs/wars may be visible through a firewall whilst Karaf console should not
> be).
>
> (2) Any way of installing wars (which are not OSGi wabs) to subdirectories?
> In tomcat I could do this by adding a "#" as part of the war name (e.g.
> hosting#fred.war could be accessed by http://hostname/hosting/fred.war).
> There isn't a similar feature in Karaf/PAX Web, is there?
>
> thanks in advance,
> Gareth
>
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Assigning-Wars-To-Ports-And-Subdirectories-tp3210710p3210710.html
> Sent from the Karaf - User mailing list archive at Nabble.com.

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com