我使用Cloudfront从cdn.myapp.com提供字体。
我正在使用font_assets gem帮助我发送CORS标头以在Firefox中接受我的字体(等等)。
我最近将我的网络服务器移到了Phusion Passenger,我对此非常满意(速度!)。
但是自从我迁移以来,我无法发送这些标题,我怀疑nginx要对它负责。
如何在Heroku上使用Phusion发送自定义标头?我可以从heroku访问nginx配置,还是有其他配置设置?
感谢您的支持!
答案 0 :(得分:2)
我尝试使用@Entity
public class CallDto {
@Id
@GeneratedValue
private Long id;
@Lob
private String callsJ;
宝石,但我花了一段时间注意到虽然使用Heroku的function myFavFood(food) {
if (food == "pizza") { alert("I love Pizza"); }
else if (food == "Hot pockets") { alert("hot pockets woo"); }
else { alert("I have bad taste in foods"); }
}
Phusion Passenger 5.0.10(Nginx)服务资产。
仅供将来参考,基于@user664833's solution,我的设置是运行在Heroku上托管的Rails 4.2应用程序,使用Phusion Passenger作为服务器,Amazon Cloudfront作为CDN,使用cdn.my-domain。 com作为分发的CNAME,仅限于rack-cors
的子域Rails 12 Factor Gem
和GET
请求:
HEAD
我编辑了缓存行为,将my-domain.com
标题列入白名单。
并将Origin Settings(Origin选项卡)更改为# config/nginx.conf.erb
location @static_asset {
gzip_static on;
expires max;
add_header Cache-Control public;
add_header ETag "";
# added configuration for CORS for font assets
if ($http_origin ~* ((https?:\/\/[^\/]*\.my-domain\.com(:[0-9]+)?)) {
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' 'true'; # only needed for SSL
add_header 'Access-Control-Allow-Methods' 'GET, HEAD';
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With';
}
# end of added configuration
}
(如果您要使用SSL)。
最后,使用Origin
清除所有内容,在“失效”标签中创建无效(如果是新配置,则无需执行此操作)。
希望这会为某人节省时间。
答案 1 :(得分:0)
从现在开始,app config中没有此选项。
此讨论:https://groups.google.com/forum/#!topic/phusion-passenger/nskVxnxFssA 解释说,这将是在不久的将来。