Skip to content

Commit

Permalink
Fix IP spoofing and invalid URI errors
Browse files Browse the repository at this point in the history
These have been noisy and not actionable, so let's fix them so we stop
getting spammed via email about them

Fixes #197 (and helps with some of #173)

Note that some URIs still do produce errors, but it's much fewer than
before anyway
  • Loading branch information
jvperrin committed Aug 13, 2019
1 parent 45533c6 commit 041ae35
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,8 @@ module Rails module Configuration
config.eager_load = true

config.log_level = :info

# Turn off ip spoofing checks, since they are spammy and not helpful since we
# don't do IP-based whitelisting
config.action_dispatch.ip_spoofing_check = false
end
10 changes: 5 additions & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@
resources :shortlinks, except: :show

# Redirect to prot's subdomain, keeping the path and any extensions in the request
match '/mediawiki(/*path)', via: :all, to: redirect { |params, _| "https://prot-hkn.eecs.berkeley.edu/w/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}" }
match '/prot(/*path)', via: :all, to: redirect { |params, _| "https://prot-hkn.eecs.berkeley.edu/wiki/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}" }
match '/prot2(/*path)', via: :all, to: redirect { |params, _| "https://prot-hkn.eecs.berkeley.edu/w/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}" }
match '/mediawiki(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://prot-hkn.eecs.berkeley.edu/w/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}") }
match '/prot(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://prot-hkn.eecs.berkeley.edu/wiki/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}") }
match '/prot2(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://prot-hkn.eecs.berkeley.edu/w/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}") }

# Redirect some alumni sites that were discontinued but requested redirects to
# prevent any old links breaking
Expand All @@ -409,8 +409,8 @@
match '/~calbear/research.html', via: :all, to: redirect { "http://research.mbbaer.com/" }
match '/~calbear/research/', via: :all, to: redirect { "http://mbbaer.com/" }

match '/~chenm(/*path)', via: :all, to: redirect { |params, _| "https://www.ocf.berkeley.edu/~morganjchen/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}" }
match '/~dyoo(/*path)', via: :all, to: redirect { |params, _| "http://www.hashcollision.org/hkn/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}" }
match '/~chenm(/*path)', via: :all, to: redirect { |params, _| URI.encode("https://www.ocf.berkeley.edu/~morganjchen/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}") }
match '/~dyoo(/*path)', via: :all, to: redirect { |params, _| URI.encode("http://www.hashcollision.org/hkn/#{ params[:path] }#{ '.' + params[:format] if params[:format].present?}") }

# This section must remain at the bottom of the routes, since they are
# catch-all routes to enable arbitrary hierarchy and placement of static pages
Expand Down

0 comments on commit 041ae35

Please sign in to comment.