无法创建在Rails中具有带前导点的细分的路径(以验证“让我们加密”)

时间:2016-08-31 12:58:19

标签: ruby-on-rails ruby heroku rails-routing lets-encrypt

在Heroku上的Rails 5应用程序中,我尝试为此URL创建路由:http://beta.example.com/.well-known/acme-challenge/some-key,因此我可以使用“加密”来验证我的服务器以获取SSL证书。但是我无法在路线的任何一段中使用前导点或句点,它只返回404 Not Found。

换句话说,.well-known开头的点正在搞砸。我可以在没有点的情况下找到工作路线,或者如果点在其他地方(例如well.known),但如果点是段中的第一个字符,则它不起作用。

我从这开始:

get "/.well-known/acme-challenge/:id" => "pages#letsencrypt"

如果不起作用,我尝试使用(dynamic segment):

get ':letsencrypt_route/acme-challenge/:id', to: "pages#letsencrypt", letsencrypt_route: /[^\/]+/

这将允许片段中的任何位置...除了第一个字符,这是我需要的地方。

知道造成这种情况的原因是什么?当我尝试导航到一个段中带有前导点的网址时,它甚至不会在我的日志中显示任何内容,它只是一个直接的404。

我已经看到有些人在Rails 4和Rails 5上都遇到过这个问题,并且在使用Thin或Puma时,以及在开发和生产中都会发生这种情况。我也试过使用一些letsencrypt宝石,但它在同一点停滞不前。

这是我在两种环境中都带有宝石的Gemfile:

source "https://rubygems.org"

ruby "2.3.1"

gem "rails", "5.0.0.1"

gem "pg", "0.18.4" # postgresql database
gem "twitter-bootstrap-rails", "~> 3.2.2"

gem "active_median", "~> 0.1.0" # used with chartkick for graph reporting
gem "activerecord-session_store", require: false # save session to database
gem "acts-as-taggable-on", git: "https://github.com/mbleigh/acts-as-taggable-on" # tagging
gem "administrate", git: "https://github.com/heyogrady/administrate", branch: "rails5"
gem "analytics-ruby", "~> 2.0.0", require: "segment/analytics" # segment.io
gem "arel"
gem "autoprefixer-rails" # for CSS vendor prefixes
gem "bootbox-rails", "~>0.4" # wrappers for javascript dialogs
gem "bootstrap-switch-rails" # bootstrap-switch.js
gem "bourbon"
gem "bower-rails" # install front-end components
gem "browser" # For variants support
gem "carrierwave" # for handling file uploads
gem "carmen-rails" # country and region selection
gem "chartkick", "~> 1.2.4" # used to provide nice looking charts
gem "chronic" # natural language date parser
gem "codemirror-rails", ">= 5.11" # display source code in pattern library
gem "coffee-rails", ">= 4.1.1"
gem "coffee-script-source", ">= 1.8.0" # Coffee script source
gem "country_select" # HTML list of countries
gem "dalli" # for memcached
gem "delayed_job_active_record", ">= 4.1" # background job processing
gem "delayed_job_web", ">= 1.2.10" # web interface for delayed job
gem "devise", ">= 4.2.0"
gem "devise-async", git: "https://github.com/mhfs/devise-async", branch: "devise-4.x" # for user authentication
gem "flamegraph" # super pretty flame graphs
gem "fog", require: false # for handling s3
# gem "font_assets" # Handle Cross-Origin Resource Sharing on fonts
gem "font_assets", git: "https://github.com/ericallam/font_assets", ref: "457dcfddc4318e83679e9a0935612924b7717085"
gem "friendly_id", "~> 5.1.0"
gem "fullcontact" # social profile info from fullcontact.com
gem "fuzzy_match" # used by smart_csv_parser for contact & address mapping
gem "google-api-client", "< 0.9", require: "google/api_client" # connecting to Google API
gem "groupdate", "~> 2.1.1" # used with chartkick for graph reporting
gem "handy", git: "https://github.com/heyogrady/handy"
gem "hike" # finds files in a set of paths
gem "honeybadger" # for error tracking
gem "intercom-rails" # tracking user behavior
gem "jbuilder", ">= 2.4.1" # for building JSON
gem "jquery-fileupload-rails", "~> 0.4.6" # file uploads
gem "jquery-rails" # jQuery
gem "jquery-ui-rails" # jQuery UI
gem "json" # for parsing JSON
gem "kaminari" # pagination
gem "le" # logentries
gem "less-rails", ">= 2.7.1" # LESS => CSS
gem "lograge" # better log formatting
gem "mandrill-api" # sending and tracking emails
gem "mechanize" # for screen scraping
gem "memory_profiler" # lets us use rack-mini-profilers GC features
gem "mini_magick" # processing images
gem "newrelic_rpm" # monitor app performance
gem "nylas", "1.1.0" # emails, calendar, contacts via Nylas.com
gem "oink"
gem "omniauth" # third party authentication
gem "omniauth-google-oauth2" # Google authentication
gem "omnicontacts" # retrieve contacts from email providers
gem "open_uri_redirections" # allow OpenURI redirections from HTTP to HTTPS
gem "paper_trail" # maintain record of stripe plans & subscriptions
gem "prawn-labels" # PDF labels
gem "puma" # server
gem "public_activity" # for model activity tracking
gem "rack-mini-profiler", require: false # display page load time badge
gem "rack-timeout" # raise error if Puma doesn't respond in given time
gem "rack-zippy" # serve gzipped assets
gem "rails-deprecated_sanitizer" # Our app uses old sanitizer methods.
gem "react-rails", "~> 1.6.0"
gem "responders", "~> 2.0" # respond_with and respond_to methods
gem "rest-client"
gem "sass-rails", ">= 5.0.3"
gem "semantic-ui-sass", git: "https://github.com/heyogrady/semantic-ui-sass"
gem "select2-rails" # select/search/dropdown box
gem "selenium-webdriver", require: false # screen-scraping
gem "signet"
gem "simple_form", ">= 3.2.1" # forms made easy for rails
gem "sinatra", git: "https://github.com/sinatra/sinatra"
gem "stripe", "~> 1.15.0" # charging customers
gem "stripe_event" # Stripe webhook integration
gem "stackprof" # a stack profiler
gem "state_machines-activemodel", ">= 0.4.0.pre"
gem "state_machines-activerecord", ">= 0.4.0.pre"
gem "toastr-rails" # display toaster notifications
gem "therubyracer", platforms: :ruby
gem "turbolinks", "~> 5.0.0.beta" # faster page loads
gem "twilio-ruby" # phone and SMS services
gem "twitter-typeahead-rails", "~> 0.11.1.pre.corejavascript" # typeahead.js - autocomplete
gem "uglifier", ">= 1.0.3"
gem "uuidtools"
gem "valid_email" # email validation
gem "wicked" # multi-page wizard forms
gem "yaml_db", git: "https://github.com/heyogrady/yaml_db", branch: "monkey-patch-rails-5" # import/export yml->db
gem "yaml_dump", git: "https://github.com/vanboom/yaml_dump" # dump db records to yaml files
# gem "zeroclipboard-rails", "~> 0.1.1" # copy to clipboard

1 个答案:

答案 0 :(得分:0)

问题在于 rack-zippy gem。当我删除gem和初始化程序时,路由工作正常。

不确定根本原因是否一般是gzipping,这个特殊的宝石,或者我的Rails 5应用程序中宝石显然是多余的事实。来自rack-zippy github page

  

想在Rails v4.2或更高版本的应用中使用rack-zippy吗?它的   建议你不要! Rails 4.2+现在支持提供gzip压缩文件   直接在Rails 4.2+应用程序中不需要rack-zippy。

如果其他人遇到类似问题,我会寻找影响中间件的任何宝石或自定义。