Opened 6 years ago

Closed 6 years ago

#1652 closed defect (invalid)

Issue with seems like query strings when trying to hit API urls. Gives 404. Same url with no "?" string works fine.

Reported by: MostHated@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.10.x
Keywords: Cc:
uname -a: Linux conanmods 4.4.0-137-generic #163-Ubuntu SMP Mon Sep 24 13:14:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.10.3 (Ubuntu)
built with OpenSSL 1.0.2g 1 Mar 2016
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_v2_module --with-http_sub_module --with-http_xslt_module --with-stream --with-stream_ssl_module --with-mail --with-mail_ssl_module --with-threads --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-auth-pam --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-dav-ext-module --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-echo --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/nginx-upstream-fair --add-module=/build/nginx-Q158zN/nginx-1.10.3/debian/modules/ngx_http_substitutions_filter_module

Description

Hello,

I have been having this issue for quite some time (possibly years?) I just never had a good enough reason to dig much deeper into it, but now it is keeping me from being able to do something rather important.

The issue I am facing is, seemingly no matter how I try to configure Nginx or Wordpress anytime I try to hit the Wordpress API (seen below) with Python's Requests Oauth package, WPAPI, oauthlib, Postman, etc I always end up getting back:

    /wp-json/wp/v2/users?s=something

    {"code":"rest_no_route","message":"No route was found matching the URL and request method","data":{"status":404}}

Though, if I hit any of the following without a query string, they are fine.

     /wp-json/wp/v2/users 
     /wp-json/wp/v2/users/5
     /wp-json/wp/v2/users/%s % id

I spent 2-3 days so far trying to find answer on forums, random configs someone might have uploaded to github, asking on several forums, etc. Not much luck.

As I mentioned, currently the issue specifically is Wordpress, but I had ran into the issue a few times before over the years and it was under very similar terms, I just cannot remember precisely what framework or package, etc it was I was having issue with.

I was very much hoping it might just be a configuration issue, but I have yet to find any out there that work. I have tried several variations of the following:

    try_files $uri $uri/ /index.php?a=$uri;
    try_files $uri $uri/ /index.php$is_args$args;
    try_files $uri $uri/ /index.php?q=$uri&$args;

but unfortunately none of those helped.

I am using the standard Virtualmin install conditions for Nginx with:

	location ~ \.php$ {
		try_files $uri =404;
		fastcgi_pass unix:/var/php-nginx/15351288871711.sock/socket;
	}

The easiest way that I could find to replicate would be to use Virtualmin's LEMP stack and then add a domain and then install Wordpress from the included script installer. install the WP REST API - OAuth 1.0a Server plugin, and then just try to hit the API after making a successful Oauth connection, but that is a rather tall order for just trying to see the error. Everything I am using I believe is as up to date as it can be. At least I thought so until I looked just now. Nginx is showing 1.10.3 through the Virtualmin console. I just finished doing all pending updates that were available.

If anyone has any insight or suggestions, please do throw them my way. I am eager to move forward with my project but unfortunately can't do much more without the ability to query the api.

Thanks all!

  • MH

Change History (1)

comment:1 by Maxim Dounin, 6 years ago

Resolution: invalid
Status: newclosed

See no problems using the following sample configuration:

    server {
        listen 8080;
        server_name foo;
        root /usr/local/www/wordpress;

        location / {
            try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            include fastcgi.conf;
        }
    }

Testing with curl:

$ curl http://127.0.0.1:8080/wp-json/wp/v2/users?search=foo
[]
$ curl http://127.0.0.1:8080/wp-json/wp/v2/users?search=test
[{"id":1,"name":"test",...}]

Either way, this doesn't look like an nginx bug, but rather as a question on how to configure nginx. Please use mailing list for such questions.

Note: See TracTickets for help on using tickets.