【问题标题】:Nginx dynamic proxy configurationNginx 动态代理配置
【发布时间】:2016-08-02 15:16:02
【问题描述】:

下面是我正在尝试做的静态配置。

server {
  listen 80;
  server_name browser.shows.this.server.com;

  location / {
     proxy_set_header Host backend.server.com;
     proxy_redirect http://backend.server.com/ http://browser.shows.this.server.com/; 
  }
}

如何使backend.server.com 为每个请求动态化?我想以某种方式在请求中传递域。也许在标题中?

【问题讨论】:

    标签: nginx


    【解决方案1】:

    您应该使用 proxy_pass 而不是代理重定向。希望这会有所帮助

    或者可以写一个这样的配置

    resolver your-server-ip;
    set $upstream_endpoint http://your-url;
      location / {
         rewrite ^/(.*) /$1 break;
         proxy_pass $upstream_endpoint;
       }
    

    http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-19
      • 2021-09-03
      • 2014-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多