gpt4 book ai didi

ruby-on-rails - 无法在 Rails 中创建具有带前导点的段的路由(以验证 Let's Encrypt)

转载 作者:数据小太阳 更新时间:2023-10-29 07:38:56 30 4
gpt4 key购买 nike

在我的 Heroku 上的 Rails 5 应用程序中,我正在尝试为此 URL 创建一个路由:http://beta.example.com/.well-known/acme-challenge/some-key ,因此我可以使用 Let's Encrypt 验证我的服务器以获得 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: /[^\/]+/

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

知道是什么原因造成的吗?当我尝试导航到一个在段中有前导点的 URL 时,它甚至没有在我的日志中显示任何内容,它只是一个直接的 404。

我看到有些人在 Rails 4 和 Rails 5 上都遇到过这个问题,我在使用 Thin 或 Puma 时,在开发和生产中都遇到过这个问题。我也尝试过使用几个 letsencrypt gem,但它在同一点停止了。

这是我的 Gemfile,其中包含两种环境中的 gem:

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

最佳答案

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

不确定根本原因是一般的 gzip 压缩、这个特定的 gem,还是这个 gem 对于我的 Rails 5 应用程序显然是多余的。来自rack-zippy github page :

Want to use rack-zippy with a Rails v4.2 or greater app? Its recommended you don't! Rails 4.2+ now supports serving gzipped files directly so there's no need for rack-zippy in Rails 4.2+ apps.

如果其他人有类似的问题,我会寻找影响您的中间件的任何 gem 或定制。

关于ruby-on-rails - 无法在 Rails 中创建具有带前导点的段的路由(以验证 Let's Encrypt),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39250336/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com