如何正确更改NGINX中的位置指令?
我使用猎鹰实施了一个简单的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论