0

I implemented a simple REST API using Falcon and running it with Gunicorn. An example call looks like this

curl "http://localhost:5000/articles?limit=100"

Now I'm trying to make the API accessible using nginx, and I actually got it working using the following config file for nginx

server {
    listen 80;
    server_name xxx.xxx.xxx.xxx;

    location / {
        include proxy_params;
        proxy_pass http://localhost:5000;
    }
}

With this I can go to http://xxx.xxx.xxx.xxx/articles?limit=100 to get the respective response. The only thing I would like to do now is to change the location directive. When I change the config file to

server {
    listen 80;
    server_name xxx.xxx.xxx.xxx;

    location /test/ {
        include proxy_params;
        proxy_pass http://localhost:5000;
    }
}

I would assume that http://xxx.xxx.xxx.xxx/test/articles?limit=100 will again give me the correct response, but I get an 404. Using /test instead of /test/ doesn't help either. What am I missing?

Christian
  • 3,239
  • 5
  • 38
  • 79
  • 1
    Use `location /test/ { ... proxy_pass http://localhost:5000/; }` (note the trailing slash). Explanation is [here](https://stackoverflow.com/questions/53649885/a-little-confused-about-trailing-slash-behavior-in-nginx). – Ivan Shatsky May 05 '22 at 03:18
  • @IvanShatsky thanks so much, that did it! Feel free to submit your comment as an answer so I can mark it as correct. – Christian May 05 '22 at 04:23
  • 1
    Thanks, but I really don't want to duplicate content already existed on the SO. Meanwhile you can upvote the @RichardSmith answer. – Ivan Shatsky May 05 '22 at 04:30

0 Answers0