nginx proxy_pass 404错误,不明白为什么 [英] nginx proxy_pass 404 error, don't understand why
本文介绍了nginx proxy_pass 404错误,不明白为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将对/api的所有调用传递到我的Web服务,但是我使用以下配置不断获取404.按预期方式调用/返回index.html.有人知道为什么吗?
I am trying to pass off all calls to /api to my webservice but I keep getting 404s with the following config. Calls to / return index.html as expected. Does anyone know why?
upstream backend{
server localhost:8080;
}
server {
location /api {
proxy_pass http://backend;
}
location / {
root /html/dir;
}
}
更多信息在这里
adept@HogWarts:/etc/nginx/sites-available$ curl -i localhost/api/authentication/check/user/email
HTTP/1.1 404 Not Found
Server: nginx/1.2.1
Date: Mon, 22 Apr 2013 22:49:03 GMT
Content-Length: 0
Connection: keep-alive
adept@HogWarts:/etc/nginx/sites-available$ curl -i localhost:8080/authentication/check/user/email
HTTP/1.1 200 OK
Content-Type: application/json
Date: Mon, 22 Apr 2013 22:49:20 GMT
Transfer-Encoding: chunked
{"user":["false"],"emailAddress":["false"]}
推荐答案
此
location /api {
proxy_pass http://backend;
}
需要是这个
location /api/ {
proxy_pass http://backend/;
}
这篇关于nginx proxy_pass 404错误,不明白为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文