【发布时间】:2017-04-15 03:22:37
【问题描述】:
我在以下拱门后面有一些网络内容,为此我需要为桌面和移动客户端提供不同的内容。
客户端 > AWS Cloudfront > Nginx > ...
cloudfront 具有识别用户代理的内置功能,他们将其统一为 4 个特殊标头(例如 CloudFront-Is-Desktop-Viewer),它们是真或假。
在 Nginx 上,我正在尝试根据这些标头来决定要提供哪些内容。 例如:
location / {
if ($http_CloudFront-Is-Desktop-Viewer = true) {
proxy_pass http://upstream;
break;
}
root /var/www/static/en-US;
try_files $uri /index.html;
}
所以在上述情况下,如果 CloudFront-Is-Desktop-Viewer 值为 true,它应该转到上游,如果它为 false 或不存在,则从 nginx 获取静态文件。
但由于某种原因,我总是从 nginx 获取静态文件。 我确定这个标头正在被转发,我什至尝试使用标头修饰符直接从 chrome 发送它。
我错过了什么?
非常感谢
【问题讨论】:
标签: web-services nginx web http-headers amazon-cloudfront