Message "301 Moved Permanently" began to appear suddenly

Asked

Viewed 1,864 times

2

I have two applications that worked perfectly, however, without changes in the code, no longer work.

On one side, an application with a JSP making a call POST and passing two parameters Hidden:

<li>
 <form name="login" method="post" action="http://dominio.com/aplicacao/chamadaApp">
  <input type="hidden" name="param1" value="conteudo1">
  <input type="hidden" name="param2" value="conteudo2">
  <A href="javascript:login()" class="classe1"></A>
  <script type="text/javascript">
   function login()
   {
    document.login.submit();
   }
  </script>
 </form>
</li>

On the other hand, another Springmvc application with the following code snippet, receiving the above request:

@RequestMapping(value = "/chamadaApp", method = RequestMethod.POST)
    public ModelAndView login(
      @RequestParam(value = "param1", required = false) String param1,
      @RequestParam(value = "param2", required = false) String param2,
      WebRequest request) {
 //código
}

It worked perfectly, however, overnight, the Springmvc application started to return the error HTTP Status 405 - Request method 'GET' not supported. This makes no sense, as both HTML performs a call POST how much the application also expects to receive a call POST.

Investigating a little more, I discovered with FIREBUG that when performing the calling App, before showing the above error, the status is returned: 301 Moved Permanently, which made me suspect some problem below, but I have no idea what it might be.

Does anyone know what that mistake means and how to fix it?

1 answer

2

This looks like a reverse proxy poorly configured, which is redirecting calls to the web server incorrectly.

Given your HTML code and the Spring Controller method, plus the information that the system has not been modified, there is no reason to think that the problem is in the application.

Scan your application server’s access logs to see what type of request it is receiving.

If you are "leaving" a POST of Firefox and coming a GET on the application server, then you "killed" the riddle and know that the problem is in the infra configuration.

You can also scan the header of incoming requests on the application server for redirect headers, such as:

  • X-Forwarded-For
  • X-Forwarded-Host
  • X-Forwarded-Server
  • Problem solved: The call to the Springmvc application was made at http (unsafe) and the server redirected to https (secure) automatically. In this redirect, it returned 301 status. By guidance of the infra support, I changed the call to be performed directly to https and started to work. It worked, but unfortunately the doubt remains and maybe it’s what you suspected: some problem in the reverse proxy, but I have no way to confirm that this is really it.

  • @dellasavia I’m glad you solved it, but there’s really no way to know exactly what happened. Probably put a new redirection rule on the down-low, only hardly the staff will admit.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.