[英]Nginx reverse proxy is not sending my http requests to server running on localhost (POST/GET)
我在ec2实例(ec2-13-229-218-180.ap-southeast-1.compute.amazonaws.com)上运行节点快递服务器。 它正在运行一个处理HTTP POST请求的Web服务器,该请求将与RDS数据库进行交互并返回查询。
我的目标是例如向端点发送POST / GET请求(ec2-13-229-218-180.ap-southeast-1.compute.amazonaws.com/getData),并使nginx理解并将其转换为POST / GET请求到http:// localhost:3000 / getData )
据我了解,我必须像这样设置nginx配置:
server {
listen 80;
listen [::]:80;
root /var/www/example.com/html;
index index.html index.htm index.nginx-debian.html;
server_name ec2-13-229-218-180.ap-southeast-1.compute.amazonaws.com;
location / {
proxy_server http://localhost:3000;
//other stuff
}
}
Nginx可以使用当前配置运行,但是当我尝试测试将发帖请求发送到ec2-13-229-218-180.ap-southeast-1.compute.amazonaws.com/getData时,我得到了404。 谁能帮我这个? 谢谢。
在服务器块外部添加以下代码片段
upstream nodejs {
server 127.0.0.1:3000;
}
然后更换
proxy_server http://localhost:3000;
通过
proxy_pass http://nodejs;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.