CodeIgniter Forums
REST server problems in Amazon EC2 - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: Installation & Setup (
+--- Thread: REST server problems in Amazon EC2 (/thread-69282.html)

REST server problems in Amazon EC2 - thiago.bittencourt - 10-31-2017

I have a CI 3 REST project in my Vagrant machine using the box opifer/ubuntu-php7. Everything works fine in my development environment, but not in my Amazon EC2 servers.

I have two free-tier instances:
  • Ubuntu Server 16.04 LTS (HVM)
  • Ubuntu Server 14.04 LTS (HVM)
I installed Git, cloned the project and installed depencies via composer in both servers. And also created the config.php and database.php files correctly.

  1. The first problem I had was about case sensitive in the name of some libraries. I have some libraries named as WhateverLibrary.php that wasn't being found by the loader. I don't know why I didn't have this problem in my development environment. I solved this by changing the /system/core/Loader.php, doing:

    PHP Code:
    protected function _ci_load_library($class$params NULL$object_name NULL)
       // ...

       //$class = ucfirst($class);
       $class ucfirst(str_replace('library''Library'$class)); // workaround to fix prod bug

       // ...

  2. The problem I'm facing now is about HTTP Verbs. I have a login_post() function called by the login form, but when I submit the form the server is returning "Unknow method".
    After debugging CI 3 core code I got to know that $this->server('REQUEST_METHOD') is returning GET instead of POST in function method() of /system/coreInput.php.

Why this is happening and how to solve this?
And also, am I missing something in my setup? Because I'm having weird problems that I didn't have in my development environment, and the code is the same!

This is my form:
<form id="formLogin" style="margin-top: 5px;" name="formLogin" method="post" action="<?php echo site_url('login_home/login');?>">
   <div id="loginFields">
       <div class="row">
           <div class="col-md-4" style="padding: 0; margin-right: 10px;">
               <input type="email" id="login" name="login" placeholder="E-mail" class="form-control" required="required" />
           <div class="col-md-3" style="padding: 0; margin-right: 10px;">
               <input type="password" id="password" name="password" placeholder="Password" class="form-control" required="required"/>
           <div id="contentLogin" class="col-md-4" style="padding: 0;">
               <input type="submit" id="loginSubmit" name="loginSubmit" value="Enter" class="btn btn-primary"/>
           <div class="col-md-12">
               <a data-toggle="modal" data-target="#forgot_password_modal" href="#" style="color: #888686;font-size: 11px;margin-left: 124px;">forgot password</a>

And here is my controller:
PHP Code:
class Auth extends REST_Controller
   function __construct()

   public function login_post()
       $this->input->post(); // does not work

   public function login_get()
       $this->input->get(); // work!

RE: REST server problems in Amazon EC2 - thiago.bittencourt - 05-29-2018

Nevermind, I got the solution!

This was happening just because I forgot to enable mod_rewrite in my Apache.

This fixes the problem:

sudo a2enmod rewrite
sudo service apache2 restart

RE: REST server problems in Amazon EC2 - DavidMichael - 06-14-2018

An XML error document as the response body

Content-Type: application/xml

An appropriate 3xx, 4xx, or 5xx HTTP status code