nginx:上游不能正常工作

我在上游遇到问题。 当我通过https://secure.toto02.com/ords/pls/manitou/4550时,我得到了url http://backend/f?p=4550 ,出现404错误。 我想要做的是在导航器中保留https://secure.toto 02.com/ords/pls/manitou/4550 ,而上游将请求发送到http://192.167.1.79:8080/ords/f?p=4550 。 我想保持隐藏的请求。

我不知道nginx服务器configuration文件有什么问题。任何人都可以帮忙吗?

 upstream backend { server 192.167.1.79:8080; } server { listen 443 ssl spdy; server_name secure.toto02.com; ssl on; ssl_certificate /etc/nginx/ssl/server.crt; ssl_certificate_key /etc/nginx/ssl/server.key; location ~ "^/(.*)/pls/ords/(\d{1,4})$" { proxy_pass http://backend/ords/f?p=$2; } } 

您正在使用proxy_pass指令中的variables,这使得您的上游服务器redirect被直接转发到客户端,因为nginx无法猜测要做什么。 这就是为什么你在浏览器中得到这个结果的原因。

确保您的上游服务器正确地使用与nginx相同的上下文来回答http://192.167.1.79:8080/ords/f?p=4550

比如这里至less有两件事情出错了:

  • 你忘了把你的真实域名replace掉,所以nginx使用的是Host: backend
  • 您的上游服务器redirect/ords/f?p=4550 (根据您的意见) /ords/f?p=4550:1: