You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Francesco Piraneo G." <ma...@piraneo-canepa.ch> on 2018/03/28 11:17:52 UTC

[users@httpd] mod_allowmethods to get all the http methods working

Hi all,

I'm developing a REST api based on PHP 7.1 and Apache 2.4 (under ubuntu 
17.10). The api requires the following methods working:

GET POST OPTIONS PUT DELETE

After a lot of googling and asking to other colleagues I finally arrived 
at mod_allowmethods so I changed my configuration in the following way:

<VirtualHost *:80>
     ServerName myserver.org
     ServerAlias be.myserver.org

     ServerAdmin xxx@yyy.ch
     DocumentRoot /var/www/be.myserver.org/

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

     DocumentRoot /var/www/be.myserver.org/

*    <Location "/">**
**        AllowMethods OPTIONS GET POST PUT DELETE**
**    </Location>**
*
     ServerSignature Off
</VirtualHost>

Of course I enabled the mod_allowmethods:

# apache2ctl -M
Loaded Modules:
  core_module (static)
  so_module (static)
  watchdog_module (static)
  http_module (static)
  log_config_module (static)
  logio_module (static)
  version_module (static)
  unixd_module (static)
  access_compat_module (shared)
  alias_module (shared)
*allowmethods_module (shared)*
  auth_basic_module (shared)
  authn_core_module (shared)
  authn_file_module (shared)
  authz_core_module (shared)
  authz_host_module (shared)
  authz_user_module (shared)
  autoindex_module (shared)
  deflate_module (shared)
  dir_module (shared)
  env_module (shared)
  filter_module (shared)
  mime_module (shared)
  mpm_prefork_module (shared)
  negotiation_module (shared)
  php7_module (shared)
  reqtimeout_module (shared)
  setenvif_module (shared)
  status_module (shared)

I included the list of all enabled modules just to be sure there are no 
other modules conflicting.

Thanks everybody for help! I'm sure that someone that is an Apache guru 
can help me solve this nasty question!

Francesco



Re: [users@httpd] mod_allowmethods to get all the http methods working

Posted by Daniel Ferradal <df...@apache.org>.
Hello,

You need to check two things.

* Are you really landing in that virtualhost? Check "apachectl -S"
output for the virtualhosts you have. Make sure there are no duplicate
servernames used in different virtualhosts and that prior virtualhost
witout servername or a greedy serveralias is not catching these
requests thus making the virtualhost you showed us useless.

* Second, it could be good to examine the headers (hint: curl -v) so
it is not your backend (the entity that really handles those requests,
the php framework) to discard it is not apache but that one forbidding
the PUT command (Hint: X-Powered-By header can usually reveal who is
dealing with that).

Regards

2018-03-28 13:23 GMT+02:00 Francesco Piraneo G. <ma...@piraneo-canepa.ch>:
> Sorry... I forgot a relevant part of my question: What's happens! (hard day
> today)
>
> When I try to access to the api with the PUT or DELETE method, Apache2
> answer with:
>
> 192.168.1.22 - - [28/Mar/2018:11:09:06 +0200] "PUT /group/users/ HTTP/1.1"
> 405 489 "-" "PostmanRuntime/7.1.1"
>
> (Basically a 405 - Method not allowed).
>
> I've found another solution that include the rewriting of url but this
> conflict with xdebug and with phpmyadmin, so I cannot use this solution and,
> frankly speaking, it looks to me like a workaround and not a "real"
> solution.
>
> Thank again for help!
>
> Francesco
>
>
>
>
> Il 28.03.18 13:17, Francesco Piraneo G. ha scritto:
>
> Hi all,
>
> I'm developing a REST api based on PHP 7.1 and Apache 2.4 (under ubuntu
> 17.10). The api requires the following methods working:
>
> GET POST OPTIONS PUT DELETE
>
>
> ...



-- 
Daniel Ferradal
HTTPD Project
#httpd help at Freenode

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_allowmethods to get all the http methods working

Posted by "Francesco Piraneo G." <ma...@piraneo-canepa.ch>.
Sorry... I forgot a relevant part of my question: What's happens! (hard 
day today)

When I try to access to the api with the PUT or DELETE method, Apache2 
answer with:

192.168.1.22 - - [28/Mar/2018:11:09:06 +0200] "PUT /group/users/ 
HTTP/1.1" *405* 489 "-" "PostmanRuntime/7.1.1"

(Basically a 405 - Method not allowed).

I've found another solution that include the rewriting of url but this 
conflict with xdebug and with phpmyadmin, so I cannot use this solution 
and, frankly speaking, it looks to me like a workaround and not a "real" 
solution.

Thank again for help!

Francesco




Il 28.03.18 13:17, Francesco Piraneo G. ha scritto:
>
> Hi all,
>
> I'm developing a REST api based on PHP 7.1 and Apache 2.4 (under 
> ubuntu 17.10). The api requires the following methods working:
>
> GET POST OPTIONS PUT DELETE
>
>
...

Re: [users@httpd] mod_allowmethods to get all the http methods working

Posted by Nick Kew <ni...@apache.org>.
On Wed, 2018-03-28 at 13:17 +0200, Francesco Piraneo G. wrote:

> After a lot of googling and asking to other colleagues I finally
> arrived at mod_allowmethods so I changed my configuration in the
> following way:

Looks like a red herring to me.  What you need is your handler
to *support* the methods in question.  C.f. mod_dav, for example.

-- 
Nick Kew


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org