You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ed _ <ed...@hotmail.com> on 2007/07/22 00:16:58 UTC

Serving up Static Pages - symlink - allowLinking

Hi,I am trying to serve up static pages / documents via tomcat. I have been google and searching the forums and have tried a couple of things suggested in the past, but haven't had success as yet.I am using tomcat 6.0 I have my webapp - say appXYZ viz accessible as http://myhost:myport/appXYZI don't care whether I end up creating another context or a path under the existing application path.ie I will be fine in either scenario 1. - http://myhost:myport/appXYZ/docStore 2. http://myhost:myport/docStoreFor Scenario 2 - I tried this suggestion - http://www.mail-archive.com/users@tomcat.apache.org/msg12528.htmlI created docStore.xml  as follows <Context  docBase="/opt/abc/workspace/store" ></Context>and put it under $Catalina_Home/webapps/  , where it is sitting at the same level as my existing application appXYZ/I was unable to access the files - nor do I see the context listed under tomcat manager.I tried to access it as http://myhost:myport/docStore/doc1.html ( where doc1.html is in my docBase file structure) I am assumed I did not have to create any soft links anywhere.For the first scenario - I edited my applications META-INF/context.html to make it as follows -<Context path="/store" docBase="/opt/abc/workspace/vvavesStore" allowLinking="true" debug="5"><Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"      driverName="org.gjt.mm.mysql.Driver"   connectionURL="jdbc:mysql://localhost:3306/authority?user=vvaves&amp;password=vvaves"       userTable="subscriber_tbl" userNameCol="sub_name" userCredCol="sub_password"   userRoleTable="subscriber_tbl" roleNameCol="sub_role"/></Context>I am a bit confused about the path here - so I did try it with /appXYZ/store  and the value as shown.In either case I tried to access it as http://myhost:myport/appXYZ/store No luck.Hoping some one knows thisthx,ed
_________________________________________________________________
Missed the show?  Watch videos of the Live Earth Concert on MSN.
http://liveearth.msn.com

RE: Serving up Static Pages - symlink - allowLinking

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Ed _ [mailto:ed_b_71@hotmail.com] 
> Subject: Serving up Static Pages - symlink - allowLinking

Your formatting needs a lot of work.  Please try to be considerate of
your readers.  Many people use at least one space after a period, for
example.

> scenario 1. - http://myhost:myport/appXYZ/docStore

The above should require no special configuration if you _haven't_ done
something like configured a servlet mapping of "/*" in the
WEB-INF/web.xml of appXYZ.  If you have done that, you've preempted
Tomcat's DefaultServlet, which is the means of delivering static
content.

> 2. http://myhost:myport/docStore For Scenario 2 - I tried this 
> suggestion - 
> http://www.mail-archive.com/users@tomcat.apache.org/msg12528.html
> I created docStore.xml  as follows <Context  
> docBase="/opt/abc/workspace/store" ></Context>and put it 
> under $Catalina_Home/webapps/

That was a mistake in the previous e-mail; it should have been placed
in:
    conf/Catalina/[host]
where [host] is usually localhost unless you've changed the <Host>
element in server.xml.

> For the first scenario - I edited my applications 
> META-INF/context.html

Is that a typo, or did you mean context.xml?

> <Context path="/store" docBase="/opt/abc/workspace/vvavesStore"

Neither the path nor docBase attributes are allowed in this situation.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: [Apache2.2.4/modjk/Tomcat6.0.13] redirect url problem

Posted by Dan Beaulieu <db...@byallaccounts.com>.
The reason was I had my rewrite directives in httpd.conf, when they should
have been nested under the virtual host in httpd-ssl.conf. Guess I forgot to
mention/remember I am using ssl. So I've got it working, thank you for your
help, but it's still unclear why we can't point two different paths at the
same context/webapp. Suppose I wanted a solution that only involved Tomcat?
It wouldn't be possible.

Thanks again.

Dan

-----Original Message-----
From: Rainer Jung [mailto:rainer.jung@kippdata.de] 
Sent: Tuesday, July 24, 2007 5:48 PM
To: Tomcat Users List
Subject: Re: [Apache2.2.4/modjk/Tomcat6.0.13] redirect url problem

Since you want to do an internal URL rewriting, it doesn't make much 
sense to me, to use a full URL including protocol and host. I would try 
the line, you commented out, instead. I guess, that you already tried that.

You should definitely see log entries in the rewrite log, if the module 
  is doing anything. Maybe there's a problem with the spaces in the path?

Mske sure, the Apache user can write to the file, so it wasn't created 
during a test run by a user with other privileges.

Why is your JkOption gone?

Regards,

Rainer

Dan Beaulieu wrote:
> Yes, that's what I have been playing around with. This is the very bottom
of
> my httpd.conf:
> 
> JkWorkersFile "C:/Program Files/Apache2/conf/workers.properties"
> JkShmFile     "C:/Program Files/Apache2/logs/mod_jk.shm"
> JkLogFile     "C:/Program Files/Apache2/logs/mod_jk.log"
> JkLogLevel    debug
> JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
> jkMount  /myApp/* worker1
> 
> <IfModule rewrite_module>
>   RewriteEngine on
>   RewriteLog "C:\Program Files\Apache2\logs\rewrite.txt"
>   RewriteLogLevel 9
>   RewriteRule ^/demo/(.*)$ https://localhost/$1 [PT,NE,NC]
>   #RewriteRule ^/demo/(.*)$ /$1 [PT,NE,NC]
> </IfModule>
> 
> I've tried both those rewrite rules, and with the R flag included, no go.
> Nothing is getting written to the rewrite.txt log either, it DOES exist
> though. Only thing I am getting is "client denied by server configuration:
> C:/Program Files/Apache2/htdocs/demo" when I try to visit
> "https://localhost/demo/myApp/login.html" in my error_log. I have no idea
> how htdocs is getting used as I've modified my DocumentRoot to point
> elsewhere...(Not that that's what I want to use anyway)
> 
> I am also loading mod_jk before mod_rewrite, as I've seen that the load
> order has caused problems for some people.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [Apache2.2.4/modjk/Tomcat6.0.13] redirect url problem

Posted by Rainer Jung <ra...@kippdata.de>.
Since you want to do an internal URL rewriting, it doesn't make much 
sense to me, to use a full URL including protocol and host. I would try 
the line, you commented out, instead. I guess, that you already tried that.

You should definitely see log entries in the rewrite log, if the module 
  is doing anything. Maybe there's a problem with the spaces in the path?

Mske sure, the Apache user can write to the file, so it wasn't created 
during a test run by a user with other privileges.

Why is your JkOption gone?

Regards,

Rainer

Dan Beaulieu wrote:
> Yes, that's what I have been playing around with. This is the very bottom of
> my httpd.conf:
> 
> JkWorkersFile "C:/Program Files/Apache2/conf/workers.properties"
> JkShmFile     "C:/Program Files/Apache2/logs/mod_jk.shm"
> JkLogFile     "C:/Program Files/Apache2/logs/mod_jk.log"
> JkLogLevel    debug
> JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
> jkMount  /myApp/* worker1
> 
> <IfModule rewrite_module>
>   RewriteEngine on
>   RewriteLog "C:\Program Files\Apache2\logs\rewrite.txt"
>   RewriteLogLevel 9
>   RewriteRule ^/demo/(.*)$ https://localhost/$1 [PT,NE,NC]
>   #RewriteRule ^/demo/(.*)$ /$1 [PT,NE,NC]
> </IfModule>
> 
> I've tried both those rewrite rules, and with the R flag included, no go.
> Nothing is getting written to the rewrite.txt log either, it DOES exist
> though. Only thing I am getting is "client denied by server configuration:
> C:/Program Files/Apache2/htdocs/demo" when I try to visit
> "https://localhost/demo/myApp/login.html" in my error_log. I have no idea
> how htdocs is getting used as I've modified my DocumentRoot to point
> elsewhere...(Not that that's what I want to use anyway)
> 
> I am also loading mod_jk before mod_rewrite, as I've seen that the load
> order has caused problems for some people.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: [Apache2.2.4/modjk/Tomcat6.0.13] redirect url problem

Posted by Dan Beaulieu <db...@byallaccounts.com>.
Yes, that's what I have been playing around with. This is the very bottom of
my httpd.conf:

JkWorkersFile "C:/Program Files/Apache2/conf/workers.properties"
JkShmFile     "C:/Program Files/Apache2/logs/mod_jk.shm"
JkLogFile     "C:/Program Files/Apache2/logs/mod_jk.log"
JkLogLevel    debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
jkMount  /myApp/* worker1

<IfModule rewrite_module>
  RewriteEngine on
  RewriteLog "C:\Program Files\Apache2\logs\rewrite.txt"
  RewriteLogLevel 9
  RewriteRule ^/demo/(.*)$ https://localhost/$1 [PT,NE,NC]
  #RewriteRule ^/demo/(.*)$ /$1 [PT,NE,NC]
</IfModule>

I've tried both those rewrite rules, and with the R flag included, no go.
Nothing is getting written to the rewrite.txt log either, it DOES exist
though. Only thing I am getting is "client denied by server configuration:
C:/Program Files/Apache2/htdocs/demo" when I try to visit
"https://localhost/demo/myApp/login.html" in my error_log. I have no idea
how htdocs is getting used as I've modified my DocumentRoot to point
elsewhere...(Not that that's what I want to use anyway)

I am also loading mod_jk before mod_rewrite, as I've seen that the load
order has caused problems for some people.

-----Original Message-----
From: Rainer Jung [mailto:rainer.jung@kippdata.de] 
Sent: Tuesday, July 24, 2007 4:42 PM
To: Tomcat Users List
Subject: Re: [Apache2.2.4/modjk/Tomcat6.0.13] redirect url problem

You can do this with mod_rewrite. Don't forget to use the PT flag, when 
combining mod_rewrite and mod_jk.

If it doesn't easily work for you:

Add a RewriteLog with a high RewriteLogLevel (e.g. 9) and increase 
JkLogLevel to debug. Then you can follow the manipulation of the URL.

Regards,

Rainer

Dan Beaulieu wrote:
> Thank you for the reply, I have played around with mod_rewrite, just can't
> seem to get it going. I will have to dig deeper. 
> 
> The main problem is when we used jserv we did something like this:
> 
> ApJservMount /myApp/servlets /myApp
> ApJservMount /demo/myApp/servlets /myApp
> 
> So myApp was a zone, and they paths would be "mounted" to the same zone
> 
> But now, with mod_jk I can't do:
> 
> jkMount  /myApp/* worker1
> JkMount  /demo/myApp/* worker1
> 
> Because tomcat on the other end will expect two separate contexts:
> 
> <Context path="/myApp" docBase="MyApp" debug="0"
> reloadable="true" />
> <Context path="/demo/MyApp" docBase="myApp" debug="0"
> reloadable="true" />
> 
> Two separate webapps = a session headache.
> Unless I am missing something...

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [Apache2.2.4/modjk/Tomcat6.0.13] redirect url problem

Posted by Rainer Jung <ra...@kippdata.de>.
You can do this with mod_rewrite. Don't forget to use the PT flag, when 
combining mod_rewrite and mod_jk.

If it doesn't easily work for you:

Add a RewriteLog with a high RewriteLogLevel (e.g. 9) and increase 
JkLogLevel to debug. Then you can follow the manipulation of the URL.

Regards,

Rainer

Dan Beaulieu wrote:
> Thank you for the reply, I have played around with mod_rewrite, just can't
> seem to get it going. I will have to dig deeper. 
> 
> The main problem is when we used jserv we did something like this:
> 
> ApJservMount /myApp/servlets /myApp
> ApJservMount /demo/myApp/servlets /myApp
> 
> So myApp was a zone, and they paths would be "mounted" to the same zone
> 
> But now, with mod_jk I can't do:
> 
> jkMount  /myApp/* worker1
> JkMount  /demo/myApp/* worker1
> 
> Because tomcat on the other end will expect two separate contexts:
> 
> <Context path="/myApp" docBase="MyApp" debug="0"
> reloadable="true" />
> <Context path="/demo/MyApp" docBase="myApp" debug="0"
> reloadable="true" />
> 
> Two separate webapps = a session headache.
> Unless I am missing something...

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: [Apache2.2.4/modjk/Tomcat6.0.13] redirect url problem

Posted by Dan Beaulieu <db...@byallaccounts.com>.
Thank you for the reply, I have played around with mod_rewrite, just can't
seem to get it going. I will have to dig deeper. 

The main problem is when we used jserv we did something like this:

ApJservMount /myApp/servlets /myApp
ApJservMount /demo/myApp/servlets /myApp

So myApp was a zone, and they paths would be "mounted" to the same zone

But now, with mod_jk I can't do:

jkMount  /myApp/* worker1
JkMount  /demo/myApp/* worker1

Because tomcat on the other end will expect two separate contexts:

<Context path="/myApp" docBase="MyApp" debug="0"
reloadable="true" />
<Context path="/demo/MyApp" docBase="myApp" debug="0"
reloadable="true" />

Two separate webapps = a session headache.
Unless I am missing something...

-----Original Message-----
From: Rainer Jung [mailto:rainer.jung@kippdata.de] 
Sent: Tuesday, July 24, 2007 11:35 AM
To: Tomcat Users List
Subject: Re: [Apache2.2.4/modjk/Tomcat6.0.13] redirect url problem

Hi Dan,

OK, two problems here:

1) URL encoded session ids and forwarding. I assume you are using mod_jk 
1.2.23. For this problem you already found a workaround, although the 
JkOption is not really safe. This topi will be fixed in a nicer way in 
the forthcoming version 1.2.24. The reason you can not see the 
difference in the access logs is, that the access logs show the incoming 
URL, but not the forwarded URL. Apache httpd will decode %3b into ";" 
and mod_jk will reencode before forwarding, but unfortunately the tomcat 
connector doesn't understand %3b in front of jsessionid. The JkOption 
you have chosen will forward the decoded URL.

2) Redirects for POST requests result in GET requests

I remember, that this is a well known browser problem. Maybe other users 
can help on that topic. Easiest solution would be to redirect earlier, 
i.e. before the form comes into the game. Another option would be to use 
mod_rewrite to rewrite the URL only locally, but then the browsers would 
not "learn", that they are using a wrong URL.

Regards,

Rainer


Dan Beaulieu wrote:
> 
> I am trying to migrate our current system of apache/jserv to apache tomcat
> using modjk. I am trying to shoe horn our current configuration.
> 
> I have a webapp lets call it myApp. Now some of our static content, beyond
> my control, requests urls like
> https://localhost/demo/myApp/servlets/aServlet;jsessionid=XXX.
> I've added an entry in my httpd.conf:
> 
> Redirect /demo https://localhost
> 
> When I do this, I will get a 404 with the access_log saying:
> 
> "POST
>
/demo/myApp/servlets/aServlet;jsessionid=24C7A06037BBA7AF7BB44DE5C0206F8C&Re
> questType=SomeRequest HTTP/1.1" 301 332
> "GET
>
/myApp/servlets/aServlet%3bjsessionid=24C7A06037BBA7AF7BB44DE5C0206F8C&Reque
> stType=SomeRequest HTTP/1.1" 404 1273
> 
> So, it looks like partly a url encoding problem. I searched around to find
> out whats up, and tried this directive for mod_jk:
> 
> JkOptions     +ForwardURICompat
> 
> And now in the access_log I see this
> 
> "POST
>
/demo/myApp/servlets/aServlet;jsessionid=7B08C6CF734771A220CC98D82DE33466&Re
> questType=SomeRequest HTTP/1.1" 301 332
> "GET myApp/servlets/aServlet
> %3bjsessionid=7B08C6CF734771A220CC98D82DE33466&RequestType=SomeRequest
> HTTP/1.1" 200 29
> 
> So we see that the request worked(even though the url is still encoded??),
> but its not actually redirecting the request. The POST is getting turned
> into a GET. Tomcat is responding with the proper response for a GET
request
> to "/myApp/servlets/aServlet". 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [Apache2.2.4/modjk/Tomcat6.0.13] redirect url problem

Posted by Rainer Jung <ra...@kippdata.de>.
Hi Dan,

OK, two problems here:

1) URL encoded session ids and forwarding. I assume you are using mod_jk 
1.2.23. For this problem you already found a workaround, although the 
JkOption is not really safe. This topi will be fixed in a nicer way in 
the forthcoming version 1.2.24. The reason you can not see the 
difference in the access logs is, that the access logs show the incoming 
URL, but not the forwarded URL. Apache httpd will decode %3b into ";" 
and mod_jk will reencode before forwarding, but unfortunately the tomcat 
connector doesn't understand %3b in front of jsessionid. The JkOption 
you have chosen will forward the decoded URL.

2) Redirects for POST requests result in GET requests

I remember, that this is a well known browser problem. Maybe other users 
can help on that topic. Easiest solution would be to redirect earlier, 
i.e. before the form comes into the game. Another option would be to use 
mod_rewrite to rewrite the URL only locally, but then the browsers would 
not "learn", that they are using a wrong URL.

Regards,

Rainer


Dan Beaulieu wrote:
> 
> I am trying to migrate our current system of apache/jserv to apache tomcat
> using modjk. I am trying to shoe horn our current configuration.
> 
> I have a webapp lets call it myApp. Now some of our static content, beyond
> my control, requests urls like
> https://localhost/demo/myApp/servlets/aServlet;jsessionid=XXX.
> I've added an entry in my httpd.conf:
> 
> Redirect /demo https://localhost
> 
> When I do this, I will get a 404 with the access_log saying:
> 
> "POST
> /demo/myApp/servlets/aServlet;jsessionid=24C7A06037BBA7AF7BB44DE5C0206F8C&Re
> questType=SomeRequest HTTP/1.1" 301 332
> "GET
> /myApp/servlets/aServlet%3bjsessionid=24C7A06037BBA7AF7BB44DE5C0206F8C&Reque
> stType=SomeRequest HTTP/1.1" 404 1273
> 
> So, it looks like partly a url encoding problem. I searched around to find
> out whats up, and tried this directive for mod_jk:
> 
> JkOptions     +ForwardURICompat
> 
> And now in the access_log I see this
> 
> "POST
> /demo/myApp/servlets/aServlet;jsessionid=7B08C6CF734771A220CC98D82DE33466&Re
> questType=SomeRequest HTTP/1.1" 301 332
> "GET myApp/servlets/aServlet
> %3bjsessionid=7B08C6CF734771A220CC98D82DE33466&RequestType=SomeRequest
> HTTP/1.1" 200 29
> 
> So we see that the request worked(even though the url is still encoded??),
> but its not actually redirecting the request. The POST is getting turned
> into a GET. Tomcat is responding with the proper response for a GET request
> to "/myApp/servlets/aServlet". 

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


[Apache2.2.4/modjk/Tomcat6.0.13] redirect url problem

Posted by Dan Beaulieu <db...@byallaccounts.com>.

I am trying to migrate our current system of apache/jserv to apache tomcat
using modjk. I am trying to shoe horn our current configuration.

I have a webapp lets call it myApp. Now some of our static content, beyond
my control, requests urls like
https://localhost/demo/myApp/servlets/aServlet;jsessionid=XXX.
I've added an entry in my httpd.conf:

Redirect /demo https://localhost

When I do this, I will get a 404 with the access_log saying:

"POST
/demo/myApp/servlets/aServlet;jsessionid=24C7A06037BBA7AF7BB44DE5C0206F8C&Re
questType=SomeRequest HTTP/1.1" 301 332
"GET
/myApp/servlets/aServlet%3bjsessionid=24C7A06037BBA7AF7BB44DE5C0206F8C&Reque
stType=SomeRequest HTTP/1.1" 404 1273

So, it looks like partly a url encoding problem. I searched around to find
out whats up, and tried this directive for mod_jk:

JkOptions     +ForwardURICompat

And now in the access_log I see this

"POST
/demo/myApp/servlets/aServlet;jsessionid=7B08C6CF734771A220CC98D82DE33466&Re
questType=SomeRequest HTTP/1.1" 301 332
"GET myApp/servlets/aServlet
%3bjsessionid=7B08C6CF734771A220CC98D82DE33466&RequestType=SomeRequest
HTTP/1.1" 200 29

So we see that the request worked(even though the url is still encoded??),
but its not actually redirecting the request. The POST is getting turned
into a GET. Tomcat is responding with the proper response for a GET request
to "/myApp/servlets/aServlet". 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org