【发布时间】:2017-11-27 04:52:08
【问题描述】:
https://docs.microsoft.com/en-us/azure/cdn/cdn-rules-engine-reference-features 此处没有足够的关于重写规则的文档。刷新也需要 4 小时,因此尝试各种正则表达式组合是不切实际的。
我有一个托管在 Azure Blob 上的 Angular 2 单页应用程序(英雄示例应用程序),并希望从 Azure CDN 提供它。但是,Angular 2 路由需要特殊处理,即将路由重写为 index.html。这是我使用 NGINX 代理的工作示例。如何将其转换为 Azure Verizon Premium CDN?
# Filename: /etc/nginx/nginx.conf
http {
...
rewrite_log on;
server {
listen 80;
server_name www.heroes.com;
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;
location / {
error_log /var/log/nginx/rewrite.log notice;
rewrite '^(\/(\w+))*\/?(\.\w{5,})?\??([^.]+)?$' /heroes/index.html break;
proxy_pass https://xxxxxx.blob.core.windows.net/heroes/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
}
}
【问题讨论】:
-
使用这个正则表达式解决方案:regex101.com/r/KK0jCN/52。不幸的是,测试需要几个小时... ...
标签: angularjs azure nginx azure-cdn