大网数据广告活动
服务器运维问答

How can I add in Apache Feature Policy Header?

· 52CE 我爱测

I have a multimedia site which offers users to upload their own media (video,music) or embed media from sites like YouTube, Vimeo etc. Recently, new header is being announced. I tried to add this header but I believe I made a mis…

问题原文

原帖链接 · Pelin Canikli · CC BY-SA 4.0

I have a multimedia site which offers users to upload their own media (video,music) or embed media from sites like YouTube, Vimeo etc.

Recently, new header is being announced. I tried to add this header but I believe I made a mistake somewhere.

This is how I tried to add this header;

Header always set Feature-Policy "vibrate 'self'; usermedia '*'; microphone 'none'; payment 'none'; sync-xhr 'self' mysiteURL.com"

Getting these error below;

Error with Feature-Policy header: Unrecognized feature: 'vibrate'.
(index):1 Error with Feature-Policy header: Unrecognized feature: 'usermedia'.
(index):1 Error with Feature-Policy header: Unrecognized origin: 'mysiteURL.com'.
(index):1 Error with Feature-Policy header: Unrecognized feature: 'vibrate'.
(index):1 Error with Feature-Policy header: Unrecognized feature: 'usermedia'.
(index):1 Error with Feature-Policy header: Unrecognized origin: 'mysiteURL.com'.

Any help will be appreciated!

已采纳解答

原帖链接 · Barry Pollard · CC BY-SA 4.0

Those are web browser errors not Apache errors. So the browser just doesn't support turning on of off of those features. They are very new so support for this header is not great at the moment.

The Chrome features supported so far can be seen in the code and it can be seen that vibrate and usermedia are not yet supported by Chrome.

You also appear to have a few syntax errors, specifically:

usermedia '*'

Should not have quotes around the star (though this is difficult to tell since it is not yet supported and at least one Google document also states this incorrectly).

sync-xhr 'self' mysiteURL.com

URLs should be prefixed with the scheme (https://).

So, for now, you could change your header to this to avoid those errors, (though you might want to add vibrate and usermedia back in if they ever become supported later):

Header always set Feature-Policy "microphone 'none'; payment 'none'; sync-xhr 'self' https://mysiteURL.com"

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-07-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。