javascript doesn't seem to be able to post form data (nginx server w/ php-fpm)

Posted by Jones on Server Fault See other posts from Server Fault or by Jones
Published on 2012-11-16T21:17:05Z Indexed on 2012/11/16 23:02 UTC
Read the original article Hit count: 234

Filed under:
|
|
|

So the situation is like so: I have a nginx server with php-fpm installed. All is well and the site scripts and all work perfectly. I am able to use html to POST form data and it works just fine. However, There seems to be be some correlation between javascript, the POST protocol and nothing happening. I cant seem to determine the issue.

Example: I have a user login widget that uses javascript on submit the fields and POST the data to a backend auth script which returns a server message that then populates the login box saying something like "Login Successful" followed by reloading the page to properly enable content. Problem is, nothing happens when you hit submit. I do know the setup works because i had it working on apache before migrating. Also if it makes any difference, the server is a Amazon EC2 instance using the Amazon AMI.

I really dont know where to start looking on this one, but below is my default.conf for the server:

upstream backend_get {
        server 127.0.0.1:80 weight=1;
}
upstream backend_post {
        server 127.0.0.1:80 weight=1;
}

#Main website url
server {
listen   80;
server_name  server.com;

#charset koi8-r;

access_log  logs/host.access.log  main;
error_log  logs/host.error.log;


  location / {
    root   /usr/share/nginx/html;
    index  index.php index.html index.htm;

    if ($request_method = POST)
    {
          proxy_pass http://backend_post;
          break;
    }
  }

  location ~ \.php$ {
    #fastcgi_pass   127.0.0.1:9000;
    fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
  }
}

© Server Fault or respective owner

Related posts about linux

Related posts about nginx