代码之家  ›  专栏  ›  技术社区  ›  Xentatt

为特定域应用HTTP标头

  •  1
  • Xentatt  · 技术社区  · 7 年前

    我需要补充

    • cool.myapp.com )
    • 所有请求 凉的myapp。通用域名格式 cool.myapp.com/<anything> www.example.com

    我需要它,因为我使用 iframe <iframe src='http://www.example.com'></iframe>

    因此,我计划创建这个子域并使用 <iframe src='cool.example.com/<anything>'></iframe>

    由于某些原因(其中之一是CORS问题),无法通过JavaScript和Ajax实现,因此我希望 nginx 做好这项工作。

    使现代化

    我觉得这样的解决方案可能会有所帮助

    location cool.myapp.com { proxy_pass http://www.example.com proxy_set_header Accept-Encoding ""; }

    1 回复  |  直到 7 年前
        1
  •  0
  •   Xentatt    7 年前

    我找到了解决方法。就我而言

    server {
      server_name domain.tld;
      location / {
        proxy_pass http://upstream;
        proxy_set_header Header-Name "headerValue";
      }
    }