Rails 3 提供了 match 方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:
注:(r3 代表 Rails 3,r4 代表 Rails 4)
# routes.rb| # First do a fresh install of CentOS 5.7 i386, server configuration (no GUI) | |
| # This should be performed as root since it's going to be installing a bunch of stuff | |
| # --- Update things to make sure we have the latest patches --- | |
| # Add EPEL so we can get reasonably recent packages | |
| rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm | |
| # --- Install all the packages --- # | |
| yum -y install python-whisper python-carbon graphite-web python-memcached python-ldap httpd memcached |
| ## Prepare ################################################################### | |
| # Remove RVM | |
| rvm implode | |
| # Ensure your homebrew is working properly and up to date | |
| brew doctor | |
| brew update | |
| ## Install ################################################################### |
| # FOR CENTOS 6 | |
| # Andrew Diller Jan 2012 | |
| # Get EPEL Repo installed | |
| rpm --httpproxy proxy --httpport 3128 --import https://fedoraproject.org/static/0608B895.txt | |
| rpm -Uvh http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm | |
| vi /etc/yum.repos.d/epel.repo |
| license: gpl-3.0 |
| crypto = require('crypto'); | |
| #Quick MD5 of text | |
| text = "MD5 this text!" | |
| md5hash1 = crypto.createHash('md5').update(text).digest("hex") | |
| #MD5 of text with updates | |
| m = crypto.createHash('md5') | |
| m.update("MD5 ") | |
| m.update("this ") |
| # All credit: http://stackoverflow.com/questions/4006324/how-to-atomically-delete-keys-matching-a-pattern-with-redis | |
| redis-cli [options] KEYS "prefix:*" | xargs redis-cli [options] DEL |
| #################################### | |
| # BASIC REQUIREMENTS | |
| # http://graphite.wikidot.com/installation | |
| # http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/ | |
| # Last tested & updated 10/13/2011 | |
| #################################### | |
| cd | |
| sudo apt-get update | |
| sudo apt-get upgrade |
| #!/bin/bash | |
| # The current process has unrestricted/unlimited (root) access when the Effective User ID (EUID) is 0: | |
| if [[ $EUID -ne 0 ]]; then | |
| echo -e "\e[1;31mThis script must be run as root or it will fail\e[0m" 1>&2 | |
| exit 1 | |
| fi | |
| # Make sure we are on CentOS | |
| OS=`cat /etc/redhat-release | awk {'print $1}'` |
| <VirtualHost *:80> | |
| ServerName kibanatest.buskas.org | |
| ServerAlias kibanatest.buskas.org | |
| Use logstash_log kibanatest.buskas.org kibanatest.buskas.org | |
| DocumentRoot "/var/www/kibana3" | |
| # Elasticsearch API is behind /es/ | |
| RewriteEngine On | |
| RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|DELETE) | |
| RewriteRule .* - [F] | |
| RewriteCond %{LA-U:REMOTE_USER} !^$ |