java 使用域转发设置登录时出现 HTTP 状态 408 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1727668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTTP Status 408 error during login with domain forwarding set up
提问by Champ
On my site wemanageloans.com, many of the users are getting the following error when they try to login with the correct credentials:
在我的网站 wemanageloans.com 上,许多用户在尝试使用正确的凭据登录时遇到以下错误:
HTTP Status 408 - The time allowed for the login process has been exceeded. If you wish to continue you must either click back twice and re-click the link you requested or close and re-open your browser
HTTP 状态 408 - 已超过登录过程允许的时间。如果您想继续,您必须单击返回两次并重新单击您请求的链接或关闭并重新打开浏览器
This happens only if they try to login from URL: http://www.wemanageloans.com
只有当他们尝试从 URL 登录时才会发生这种情况:http: //www.wemanageloans.com
I have set up domain forwarding to URL: http://59.176.19.181:8080
我已将域转发设置为 URL:http: //59.176.19.181: 8080
This error does not happen if the user tries to access the above IP address based URL directly.
如果用户尝试直接访问上述基于 IP 地址的 URL,则不会发生此错误。
Also, while this error occurs all the time for some users, it does happen intermittently to some users.
此外,虽然此错误对于某些用户来说一直发生,但它确实会间歇性地发生在某些用户身上。
Please advise as to what could be wrong with the domain forwarding and what I may need to configure on my side.
请告知域转发可能出现的问题以及我可能需要配置的内容。
I am using Tomcat 6' authentication using j_security_check.
我正在使用 Tomcat 6' 身份验证,使用j_security_check.
回答by Olaf Kock
When I visited the site I've seen that the session cookie was not immediately set - not even after the first login attempt.
当我访问该站点时,我发现会话 cookie 没有立即设置 - 即使在第一次登录尝试之后也没有设置。
I guess that there's something wrong with the start of a session.
我想会话开始时有问题。
As "forwarding" is done through a frame that masks your site, I'd suggest to stop this: it obfuscates quite a bit of what happens. Either get correct DNS resolution, use mod_jk or similar to serve tomcat content through apache or just redirect people to directly use the IP. This will most likely get rid of your problems (I've never seen them in this scenario). In case of using the IP directly it results in an ugly URL, so correct DNS resolution should be what you aim for.
由于“转发”是通过屏蔽您网站的框架完成的,我建议停止这种做法:它混淆了很多发生的事情。要么获得正确的 DNS 解析,要么使用 mod_jk 或类似方法通过 apache 提供 tomcat 内容,要么只是重定向人们以直接使用 IP。这很可能会解决您的问题(我从未在这种情况下见过它们)。如果直接使用 IP 会导致丑陋的 URL,因此正确的 DNS 解析应该是您的目标。
Edit:Don't know if you already do this: Keep in mind that - using j_security_check - you can't just provide the login form to the user but need to rely on tomcat to present it (AFAIK). Therefor your page http://59.176.19.181:8080/personalcredit/loans.htm(which is the first page shown) is not supposed to have the login form on it, instead the page has to be declared as protected, so that tomcat by itself provides the configured login page to the user. If loans.htm was not declared protected, there was no reason for tomcat to start a new session which would explain the observed behaviour.
编辑:不知道你是否已经这样做了:请记住 - 使用 j_security_check - 你不能只向用户提供登录表单,而是需要依赖 tomcat 来呈现它(AFAIK)。因此,您的页面http://59.176.19.181:8080/personalcredit/loans.htm(显示的第一页)不应该有登录表单,而是必须将页面声明为受保护的,以便 tomcat它本身向用户提供配置的登录页面。如果loans.htm 没有被声明为受保护,那么tomcat 就没有理由开始一个新的会话来解释观察到的行为。
It wouldn't explain the nondeterminism though.
但这并不能解释不确定性。
回答by vanduc1102
I fixed this issue by adding an Interval to login.htmland login-failure.html
我通过向login.html和login-failure.html添加一个间隔来解决这个问题
setInterval(function(){
location.reload(true);
},5*60*1000);
The login.htmland login-failure.htmlare the same. Except login-failure.htmlcontained a text "Username or password is incorrect"
该的login.html和登录,failure.html是相同的。除了login-failure.html包含文本“用户名或密码不正确”
回答by Bangoura
I seem to have found a very simple solution
我似乎找到了一个非常简单的解决方案
<meta http-equiv="Cache-Control" content="no-store,no-cache,must-revalidate"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="-1"/>
Thanks to Greg http://readlist.com/lists/tomcat.apache.org/users/7/35987.html
感谢格雷格 http://readlist.com/lists/tomcat.apache.org/users/7/35987.html
回答by KB22
Could be caching related. Try sending a header like:
可能与缓存有关。尝试发送一个标题,如:
Cache-Control: no-cache,no-store,must-revalidate
Pragma: no-cache
Just to rule this option out...
只是为了排除这个选项......
Anyways 408 is about timeouts, could it be that your server takes more time to route those requests? Unlikely, but possbile though.
无论如何,408 是关于超时的,是不是您的服务器需要更多时间来路由这些请求?不太可能,但可能。
Another approach would be to set your tomcat server.xml to listen to port 80, just to make sure that using port 8080 is not causing the problem...
另一种方法是将您的 tomcat server.xml 设置为侦听端口 80,以确保使用端口 8080 不会导致问题...
server.xml would need to look sthing like:
server.xml 需要看起来像:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000"
redirectPort="8443" />
hth
第

