如何正确更改NGINX中的位置指令?

发布于 2025-01-26 10:27:36 字数 755 浏览 1 评论 0原文

我使用猎鹰实施了一个简单的REST API,并与Gunicorn一起运行。 现在,

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

我试图使用nginx访问API,实际上我可以使用以下nginx使用nginx来访问API,

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

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

我可以转到http://xxx.xxx.xxx.xxx .xxx/articles?limit = 100获得相应的响应。我现在唯一想做的就是更改位置指令。当我将配置文件更改为时,

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

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

我会假设http://xxx.xxx.xxx.xxx.xxx/test/articles?limit=100再次给我正确的响应,但我得到了404 。我想念什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文