NGINX反向代理响应
我使用NGINX服务器作为反向代理。NGINX服务器接受来自外部客户端的请求(HTTP或HTTPS不重要),并将该请求传递给后端服务器。后端服务器将“a”URL返回给客户端,该客户端将具有另一个URL,该URL应用于进行后续API调用。我希望这个返回的URL具有NGIX主机和端口号,而不是后端服务主机和端口号,这样我的后端服务器详细信息就永远不会公开。例如NGINX反向代理响应,nginx,proxy,Nginx,Proxy,我使用NGINX服务器作为反向代理。NGINX服务器接受来自外部客户端的请求(HTTP或HTTPS不重要),并将该请求传递给后端服务器。后端服务器将“a”URL返回给客户端,该客户端将具有另一个URL,该URL应用于进行后续API调用。我希望这个返回的URL具有NGIX主机和端口号,而不是后端服务主机和端口号,这样我的后端服务器详细信息就永远不会公开。例如 1) Client request: http://nginx_server:8080 2) Nginx receives this a
1) Client request:
http://nginx_server:8080
2) Nginx receives this and passes it to the backend running with some functionality at
http://backend_server:8090
3) The backend server receives this request and passes another URL to the client http://backend_server:8090/allok.
4) The client uses this URL and makes another subsequent API calls.
我想要的是,在响应的步骤4中,“backend_server:port”被初始请求中的nginx服务器和端口替换。例如
http://nginx_server:8080/allok
然而,人们的反应可以追溯到
http://backend_server:8090/allok
我的nginx.conf
http {
server {
listen 8080; --> Client request port
server_name localhost;
location / {
proxy_pass http://localhost:8090; ---> Backend server port. The backend
service and NGINX will always be on the same
machine
proxy_redirect http://localhost:8090 http://localhost:8080; --> Not sure if this is
correct. Doesn't seem to do what I want to achieve
# proxy_set_header Host $host;
}
}
}
提前感谢我能够解决它。我必须从配置中删除proxy_redirect指令 我能够解决它。我必须从配置中删除proxy_redirect指令