如何将会话从一台 Tomcat 服务器转移到另一台? [英] How to transfer session from one Tomcat server to another?

查看:83
本文介绍了如何将会话从一台 Tomcat 服务器转移到另一台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个用于网店的Tomcat服务器,当他/她登录时,我们需要将用户转移到另一个(安全的)服务器.这里有一个详细的解释:

We have a Tomcat server for a web shop, and we need to transfer the user to another (secure) server when he/she logs in. Here's a detailed explanation:

1) 我们有两台 Tomcat 服务器:一台常规"(HTTP)和一台安全(HTTPS)

1) We have two Tomcat servers: one 'regular' (HTTP) and one secure (HTTPS)

2) 用户最初访问普通服务器

2) Users initially visit the regular server

3) 当他们登录时,我们需要获取他们的登录数据,以及他们当前在(或试图查看)哪个页面的信息,将其传递给安全服务器并进行实际登录;例如,一个未登录的用户看到一个产品列表,点击购买"并显示一个弹出窗口,要求用户登录;用户输入他/她的凭据,这些凭据以及有关他想购买的产品的信息将传递到安全服务器;安全服务器接收这些,执行登录并向用户显示请求的产品

3) When they log in, we need to get their log in data, as well as the information about what page they were currently on (or were trying to see), pass it to the secure server and do the actual login; for instance, a non-logged in user sees a list of products, clicks 'BUY' and a popup is displayed, asking the user to log in; the user enters his/hers credentials and these, as well as the information about what product he wants to buy, are passed to the secure server; the secure server receives these, performs the login and displays the requested product to the user

这是怎么做到的?请注意以下事项:

How could this be done? Please note the following:

1) 我们尝试过用 cookie 来做,但我们决定不那样做

1) We've tried doing it with cookies, but we've decided not to go that way

2) 将会话保留到数据库然后让安全服务器获取它也不是一种选择

2) Persisting the session to a database and then having the secure server fetch it is also not an option

还有其他方法吗?我们正在考虑创建一个对象,然后将其作为 HTTP POST 参数传递,但我不确定如何做到这一点(我已获得完成它的任务).

Are there any other ways? We were thinking about creating an object and then passing it as a HTTP POST parameter, but I'm not sure how this could be done (I've been given the task to finish it).

就其价值而言,我们使用的技术是 Tomcat 服务器、Wicket、Spring、iBatis 和 MySQL.

For what it's worth, the technologies we use are Tomcat server, Wicket, Spring, iBatis and MySQL.

提前致谢:)

推荐答案

如果您想在不同的 Tomcat 实例之间共享会话,您可以将它们配置为具有会话复制的集群:http://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html

If you want to share the session between different Tomcat instances, you could configure them to work as a cluster with session replication: http://tomcat.apache.org/tomcat-7.0-doc/cluster-howto.html

然后,您可以配置一个 Apache HTTP 服务器作为负载均衡器,确保 HTTP 请求进入服务器 1,HTTPS 请求进入服务器 2.

Then, you could configure an Apache HTTP Server to work as a load balancer, making sure that HTTP requests go to server 1 and HTTPS requests go to server 2.

但是,您也可以只配置一个 Tomcat 实例(或 N 个相同的实例)来处理 HTTP 和 HTTPS,并确保使用标准(...<transport-guarantee>CONFIDENTIAL</transport-guarantee>... in web.xml) 或特定于框架的配置.

But, you could also have only one Tomcat instance (or N identical instances) configured to handle both HTTP and HTTPS, and ensure the secure access with standard (...<transport-guarantee>CONFIDENTIAL</transport-guarantee>... in web.xml) or framework-specific configuration.

这篇关于如何将会话从一台 Tomcat 服务器转移到另一台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆