10

I have a Rails app with jquery-ui sortable lists. When the user drags from one list to another the wostatus_id field gets updated. So, it's failing on a jquery Ajax update.

This works fine in localhost and on Heroku. But, I'm moving the app to a Bitnami Virtual Server + Rails implementation. I don't know if it's related, but I'm using node.js on the new server.

On this new server, I'm getting this error on the browser console:

PUT http://ndeavor.ameipro.com/workorders/2 501 (Not Implemented) 

enter image description here

This is the coffee script:

  $("#sort1, #sort2, #sort3, #sort4, #sort5, #sort6, #sort7").sortable
    connectWith: ".connectedSortable"
    cursor: "move"
    update: ->
      $.post($(this).data('update-url'), $(this).sortable('serialize'))
    receive: (event, ui) ->
      str_id =  $(ui.item).attr('id')
      woid = str_id.split('_')[1]
      $.update "/workorders/" + woid,
        workorder:
        wostatus_id: $(this).data('wostatus-id')

Thanks for the help!

UPDATE1

I'm getting the same error when I drag an event from one day to another using the fullcalendar-rails month view.

UDPATE2

I found this "Fixing 501 error code The client should specify a valid request type. Even after that if the Web server is responding incorrectly, then the web server simply needs to be upgraded to fix the issue."

I'm sure the request is OK - the same code has been running on localhost and Heroku for months. So, it has to be something to do with the new virtual server I'm using.

The new server is Bitnami Rails stack. It has node.js installed. I'm running Apache, Passenger and PG.

How would I upgrade the server to fix the problem???

UPDATE3

This coffeescript gets the same response:

updateEvent = (the_event) ->
 $.update "/events/" + the_event.id,
   event:
     title: the_event.title,
     starts_at: "" + the_event.start,
     ends_at: "" + the_event.end,
     description: the_event.description

UPDATE4

Could Apache be stopping the use of PUT? Maybe some setting in https.conf?

UPDATE5

The same app runs fine using Thin !!!! So, I'm going to try and use Nginx and Thin.

UPDATE6

I can't get it to work. So, I'm going to try Nginx and 5 Thin app servers.

UPDATE7

I now have the Rails app running on Nginx and 5 Thin servers. I still get the 501 PUT - jquery error !!!!

If I run Thin in stand-alone on port 3000, it works fine.

If I run Thin stand-alone on port 80, I get the same JQUERY PUT 501 error.

So, something is wrong with our servers using port 80.

Reddirt
  • 5,913
  • 9
  • 48
  • 126
  • is it close to your problem ? https://www.geekisp.com/forum/index.php?topic=36.0;prev_next=prev – rbinsztock Mar 12 '13 at 00:55
  • Senayar, it says "The load balancer filters PUT and DELETE by default". If that's my issue, do you know how I can enable them? – Reddirt Mar 12 '13 at 13:19
  • i think the main problem come from your apache conf. check if the port used by your apache was not already used or well forwarded ? : fuser -n tcp port – rbinsztock Mar 12 '13 at 18:54
  • If I run this command in the SSH console = $ fuser -n tcp port, I get Cannot resolve local port port: Servname not supported for ai_socktype – Reddirt Mar 12 '13 at 19:12
  • If I run this command in the SSH console = $ fuser -n tcp 80, I get nothing – Reddirt Mar 12 '13 at 19:18
  • If I use sudo, I get 80/tcp: 7577 7597 7598 7599 7600 7601 7632 7646 10397 10399 10400 (What does it mean?) – Reddirt Mar 12 '13 at 19:19

5 Answers5

4

I spent almost 2 weeks working on this. I have tried Apache+Passenger and Nginx+Thin.

It ends up that none of those were the cause. It had nothing to do with the Rails app setup.

It was a Pound networking server that was stopping PUT.

Reddirt
  • 5,913
  • 9
  • 48
  • 126
2

Check for the Limit keyword on your apache configuration.

chances are that by default you have something like that somewhere:

<Limit PUT DELETE>
    order deny,allow
    deny from all
</Limit>

This prevent the web server from accepting any PUT or DELETE request, thus the 501 (Not Implemented).

UPDATE:

So the thing you have found are:

<Limit GET POST OPTIONS>
    Order allow,deny
    Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
    Order deny,allow
    Deny from all
</LimitExcept>

This means only GET, POST and OPTIONS queries are accepted (allow from all) and anything not in this list (LimitExcept) is denied (Deny From All).

If you need the PUT keyword then add it in theses two settings (Limit and LimitExcept).

Note that theses limits are only applied for /home/*/public_html directories.

regilero
  • 29,806
  • 6
  • 60
  • 99
  • I found one conf file with limit https-userdir.conf. Here's a link to it: https://dl.dropbox.com/u/35302780/httpd-userdir.conf But, it's not a limit on PUT. Still, could it be the problem? – Reddirt Mar 13 '13 at 14:20
  • I changed the https-userdir.conf to look list this: https://dl.dropbox.com/u/35302780/httpd-userdir.conf Then I restarted Apache. But, the error didn't go away. I'm going to spend more time searching conf files. – Reddirt Mar 13 '13 at 15:51
  • are you using a public_html directory? – regilero Mar 13 '13 at 16:36
  • I'm using a Bitnami Rails and Postgres stack. I use Capistrano to deploy. I'm running Apache and Passenger. My app gets put into this directory DocumentRoot "/opt/bitnami/projects/ndeavor/current/public" So, I'm using a public directory. But, not public_html -- I think. – Reddirt Mar 13 '13 at 16:49
  • check for apache conf hidden in any .htaccess on all parents directory of your project directory -- and in this projet dir) – regilero Mar 13 '13 at 17:18
  • In order to see the hidden Apache files, do I change this file: /opt/bitnami/apache2/conf/extra/httpd-autoindex.conf This line: IndexIgnore .??* ~ *# HEADER README* RCS CVS ,v *,t To this: IndexIgnore *~ *# HEADER README* RCS CVS *,v *,t – Reddirt Mar 13 '13 at 18:06
  • I looked in the https.conf file and it has this: # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None Doesn't that mean that no .htaccess files can be used? – Reddirt Mar 13 '13 at 18:17
1

Have you tried synthesizing a request without the sortable? I have this sneaking suspicion that JUI is adding crazy temp elements that's formatting your request insanely.

Alternatively, whenever something works locally but not on the server, I figure that something isn't asynchronous that should be.

Instead of making a request on sort, log out the request's parameters. Do they make sense?

MrLeap
  • 506
  • 2
  • 11
1

well if your server apache is well configured with Virtualhost. using gem install passenger and passenger-install-apache2-module into your rails app. So he tells you what you need to add into your file httpd.conf. Usually you got something close to this.

Listen *:80
NameVirtualHosts *:80


LoadModule passenger_module /somewhere/passenger-x.x.x/ext/apache2/mod_passenger.so

PassengerRuby /usr/bin/ruby
PassengerRoot /somewhere/passenger/x.x.x
PassengerMaxPoolSize 10

<VirtualHost *:80>
    ServerName www.foo.com
    DocumentRoot /webapps/foo/public
    RailsBaseURI /rails
</VirtualHost>

but i advice you to use Nginx with Passenger.

I also look at this : 501 Method Not Found error on a javascript file - change name and it then works - why?

Here you can find a tutorial to deploy Rails app with Apache : Rails 3.1 application deployment tutorial

Community
  • 1
  • 1
rbinsztock
  • 3,025
  • 2
  • 21
  • 34
0

Had the same issue, looking at the POUND reverse proxy server configuration as someone else suggested and changing the xHTTP to the value of 1 fixed it for me.

http://manpages.ubuntu.com/manpages/xenial/man8/pound.8.htmlSee ubuntu POUND config details