[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

when I Proxy Pass I lose the java session.

Posted on 2004-11-11
11
Medium Priority
?
892 Views
Last Modified: 2008-02-01
hi,

I have searched the web for two days without getting answer to this, so I turn to the experts :)

I'm using Sun Java System Application Server (Platform Edition 8.0.0_01) to run my java programs on, and they work on it.

Then I have an apache running on port 80 and proxypass my application server on that apache.
here is how I do that:

<VirtualHost *:80>
    ServerAdmin webmaster@aripall.com
    DocumentRoot c:\\www\\aripall.com\\htdocs
    ServerName www.aripall.com
    ServerAlias aripall.com
    ErrorLog c:\\www\\aripall.com\\logs\\error.log
    CustomLog c:\\www\\aripall.com\\logs\\acces.log common
       
    ProxyRequests Off
    ProxyPass / http://www.aripall.com:8001/myapp/
    ProxyPassReverse / http://www.aripall.com:8001/myapp/

</VirtualHost>


With the configuration above I always get a new session when I go to www.aripall.com (through the proxy pass) , but when I access the "orginal" location of it with  http://www.aripall.com:8001/myapp/ I do not lose the session.

to simplify the problem. If I write in a jsp page, out.println("sessionId: "+session.getId()) I always get the same sessionId when I refresh the page if I go straigth to the application server, but do always get a different sessionId when I go through the proxy pass.

cheers from Iceland
 Kjarri
0
Comment
Question by:Kjarrialberts
  • 6
  • 5
11 Comments
 
LVL 13

Accepted Solution

by:
petmagdy earned 1600 total points
ID: 12561586
alright
I will try to help hopfully we can find out the solution.
 I used Apache mode_proxy before with OC4J and it works fine and the session is maintain but the only difference was not throught virtual host but like this:

make sure those was not commented
LoadModule proxy_module
AddModule mod_proxy.c

<IfModule mod_proxy.c>
    ProxyRequests On
    ProxyPass /myroot                   http://www.aripall.com:8001/myapp/
    ProxyPassReverse /myroot   http://www.aripall.com:8001/myapp/
</IfModule>
0
 

Author Comment

by:Kjarrialberts
ID: 12563977
hi and thank you very much for your answer.
Because of time different I haven't been able to answer you sooner.

I can't access the server for the next 8 hours to try out your solution, but I think it does not work for me.

I think I have to use virtual host since I'm hosting 5 domains on that server and I want each of them to point to a different java application on the application server (which is running on the same macine).
Isn't that correct that I have to use virtual host if I'm going to proxy pass diffent "roots" (for different domains) to different java applications?
that is, I could have two applications on the application server working (with the session working) on:
www.mydomain.com:8001/myapp
www.mydomain.com:8001/myotherapp

and I would like to map the root of two different domains to these apps, so:
www.mydomain.com  would proxy pass to www.mydomain.com:8001/myapp 
and
www.mydomain2.com  would proxy pass to www.mydomain.com:8001/myotherapp 
as stated before, this proxy passing works, except I always get a new session for each refresh of the jsp page.

hope this explained why I think I have to use virtual host and proxy pass there.
But I will try out your solution after 8 hours.

thanks again
  Kjarri
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12563987
yes give it a shot
and one more thing, in ut virtual host proxy why  ProxyRequests is Off?
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:Kjarrialberts
ID: 12564025
hi, wow that was a quick answer!
Yes I will try your solution soon as I can.

ProxyRequests  Off  was just something I saw on a page somewhere when I was trying to find a solution on this.
First I was  with this line NOT in, but it did not change anything to add it.... It probably should not be there, it did at least not solve my problem.
So without this line, I don't see any changes on the java session behavior.

thanks again
  Kjarri
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12564036
then can u try it on first? I think the correct value is On
0
 

Author Comment

by:Kjarrialberts
ID: 12564087
thanks, I will try it in about 7-8 hours.
0
 

Author Comment

by:Kjarrialberts
ID: 12568240
hi,

setting ProxyRequests to On, did not change anything.

by adding your lines, then calling mydomain.com/myroot have the same effect as before, the proxy pass works, but I always get different session for each refresh.

additional info:
I'm using apache2.
I (ofcourse) reboot the apache after each change before I try.

cheers
  Kjarri
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12568298
well
 I began to think this is something related to Sun AS

When i test this on OC4J it was apache 2 also
maybe it is better to use Sun AS plugin for apache
0
 

Author Comment

by:Kjarrialberts
ID: 12568436
I'm going to install OC4J to check if it works there.
0
 

Author Comment

by:Kjarrialberts
ID: 12569784
hi,
When I use OC4J this works!
the session in "unharmed" when I refresh the page.
I'm just going to use OC4J since the Sun Server is not working for this.
This is ofcouse ratical change, but it's ok for me.... the problem where not solved with the Sun Server, but this is enough for me.
cheers from Iceland
  Kjarri
0
 
LVL 13

Expert Comment

by:petmagdy
ID: 12569810
cheers welcome :)
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert websphere application server default chained Certificates from 1024 to 2048 keysize or higher size and also you can change signatureAlgorithm . Please make sure Websphere Application Server fixpack 7.0.0.23 or Above. The following steps a…
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Screencast - Getting to Know the Pipeline
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question