NGINX反向代理重定向而不是代理

时间:2018-12-24 18:07:35

标签: nginx-reverse-proxy

我有一个NGINX服务器作为反向代理运行。代理服务器适用于Windows主机,但是我有一个owncloud服务器,代理服务器会将URL改写为内部主机名或IP地址。例如(我输入cloud.example.com,我的网址栏将更改为10.1.1.19,这在广域网上是无法解决的

我已经检查了DNS记录,并确保NGINX可以解析主机名。还尝试仅将HTTP流量转发到云服务器,以确保使用域名不是问题。

server {
  listen 80;
  listen [::]:80;

  server_name example.com;

  location / {
      proxy_pass http://10.1.1.16:80/;
  }
}

server {
  listen 80;
  listen [::]:80;

  server_name cloud.example.com;

  location / {
      proxy_pass http://10.1.1.19:80/;
  }
}

server {
  listen 80;
  listen [::]:80;

  server_name remote.example.com;

  location / {
      proxy_pass http://10.1.1.17:80/;
  }
}

我只需要NGINX作为“ cloud.example.com”的代理运行,而不是重写URL

1 个答案:

答案 0 :(得分:0)

我找到了部分答案——Why is my Nginx reverse proxy doing a 301 redirect instead of proxying?

对我来说,它阻止 nginx 更改主机名(即从 good-domain.com 到 10.1.5.5:8080),但似乎没有办法阻止 nginx 将端口附加到客户端的请求网址。

因此,通过使用上面引用的答案,我能够从 http://10.1.5.5:8080 转到 http://good-domain:8080。这仍然不是我想要的地方,但它确实让我更接近了。

相关问题