Skip to content

Instantly share code, notes, and snippets.

@JingwenTian
Forked from hydra35/nginx.conf
Created April 21, 2013 13:37
Show Gist options
  • Save JingwenTian/5429607 to your computer and use it in GitHub Desktop.
Save JingwenTian/5429607 to your computer and use it in GitHub Desktop.
# 1. Make sure you have nginx sub module compiled in
# nginx -V 2>&1 | grep --color=always '\-\-with\-http_sub_module'
# 2. add two directives below at HTTP level
# nginx.conf
http {
# ......
sub_filter '</head>' '<style type="text/css">html{ filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
} img { _filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=0); -webkit-filter: grayscale(100%); filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
} </style>';
sub_filter_once on;
# ......
}
# 3. nginx -t && /etc/init.d/nginx reload
@JingwenTian
Copy link
Author

让网页变灰,为雅安哀悼。程序员们可以修改Nginx的nginx.conf文件,用sub_filter指令使得每个页面都自动变灰,不用一页一页手工修改,如www.ucloud.cn。详细配置可参考@hydra35 写的 http://t.cn/zTiZkGw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment