簡體   English   中英

Rails說,Sendgrid Devise電子郵件沒有將Heroku IP列入白名單(即使已列入白名單)。

[英]Rails says Heroku IP is not whitelisted (even though it is) for Sendgrid Devise Emails

已解決(種類)

恐怕有關該主題的大量現有問題和資源似乎都無法解決我的問題。

我從網站上收到一條成功消息,但Heroku表示,盡管我將Heroku使用的IP地址列入了白名單,但只有本地環回IP地址才被授權渲染控制台。

日志摘錄:

2015-07-06T20:20:12.137924+00:00 app[web.1]: Cannot render console from 98.117.13.138! Allowed networks: 98.117.13.138, 127.0.0.0/127.255.255.255, ::1

application.rb白名單:

config.web_console.whitelisted_ips = '98.117.13.138'

以下是相關的配置代碼。

我在Devise中使用Heroku和Sendgrid。 我用來測試的過程是“重置密碼”功能。

production.rb

  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  Rails.application.routes.default_url_options[:host] = 'my_host_address'

smtp.rb初始化程序

  ActionMailer::Base.smtp_settings = {
    :address        => "smtp.sendgrid.net",
    :port           => "587",
    :authentication => :plain,
    :user_name      => ENV['SENDGRID_USERNAME'],
    :password       => ENV['SENDGRID_PASSWORD'],
    :domain         => 'heroku.com',
    :host           => 'my_host_address'
  }

devise.rb初始化程序

Devise.setup do |config|
  config.mailer_sender = 'noreply@qwesteraherokuapp.com'
  require 'devise/orm/active_record'
  config.case_insensitive_keys = [:email]
  config.strip_whitespace_keys = [:email]
  config.skip_session_storage = [:http_auth]
  config.stretches = Rails.env.test? ? 1 : 10
  config.reconfirmable = false
  config.expire_all_remember_me_on_sign_out = true
  config.password_length = 8..72
  config.reset_password_within = 6.hours
  config.sign_out_via = :delete
config.secret_key = 'my_secret_key'
end

$ heroku日志

2015-07-06T20:20:08.968204+00:00 heroku[run.8217]: State changed from up to complete
2015-07-06T20:20:13.271484+00:00 app[web.1]: Processing by Devise::PasswordsController#new as HTML
2015-07-06T20:20:13.397112+00:00 app[web.1]:   Rendered devise/passwords/new.html.erb within layouts/application (39.7ms)
2015-07-06T20:20:13.420795+00:00 heroku[router]: at=info method=GET path="/u/users/password/new" host=qwestera.herokuapp.com request_id=21639047-f729-4cc3-bdbf-1fbcbf22760d fwd="98.117.13.138" dyno=web.1 connect=1ms service=1296ms status=200 bytes=4354
2015-07-06T20:20:13.396891+00:00 app[web.1]:   Rendered devise/shared/_links.html.erb (11.4ms)
2015-07-06T20:20:13.408958+00:00 app[web.1]: Completed 200 OK in 137ms (Views: 54.8ms | ActiveRecord: 12.6ms)
2015-07-06T20:20:13.573078+00:00 heroku[router]: at=info method=GET path="/assets/Site_Logo_Black-2a4f3fed4b2570b6f751326139586e697488ae75b60f3d19550bb1279c29922c.png" host=qwestera.herokuapp.com request_id=e96655d5-39c4-41c9-b37d-a5fd1cca66ae fwd="98.117.13.138" dyno=web.1 connect=0ms service=4ms status=304 bytes=133
2015-07-06T20:20:13.626264+00:00 heroku[router]: at=info method=GET path="/assets/bootstrap/glyphicons-halflings-regular-fe185d11a49676890d47bb783312a0cda5a44c4039214094e7957b4c040ef11c.woff2" host=qwestera.herokuapp.com request_id=3e3925f9-b3c8-4699-ba45-0fda48217fea fwd="98.117.13.138" dyno=web.1 connect=1ms service=6ms status=304 bytes=133
2015-07-06T20:20:13.584094+00:00 heroku[router]: at=info method=GET path="/assets/application-1e5c3b1b77c2c96cc6a13c45ea618b3966d23885add868456ed0df7c69558c9d.js" host=qwestera.herokuapp.com request_id=f7b586ca-4f05-418c-866d-e45a49fbb2a2 fwd="98.117.13.138" dyno=web.1 connect=4ms service=9ms status=304 bytes=133
2015-07-06T20:20:13.624068+00:00 heroku[router]: at=info method=GET path="/assets/Grey_Stripe-c8b5e65dcd52152bd03304887bcb689bd01bf10d0a6159f454c6da221ae8bee1.png" host=qwestera.herokuapp.com request_id=6c6d8122-1f27-496e-9627-484d45f1e1c6 fwd="98.117.13.138" dyno=web.1 connect=1ms service=5ms status=304 bytes=133
2015-07-06T20:20:13.562547+00:00 heroku[router]: at=info method=GET path="/assets/application-e3e49b6823ad75932b2c57d4cea86a6f8e5764b394af3a28b0779a42bbf360f4.css" host=qwestera.herokuapp.com request_id=29f4deaa-e38b-41e5-b106-077705305d71 fwd="98.117.13.138" dyno=web.1 connect=2ms service=6ms status=304 bytes=133
2015-07-06T20:20:13.656922+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=qwestera.herokuapp.com request_id=2ee0e849-277b-4996-8925-2064c10b3010 fwd="98.117.13.138" dyno=web.1 connect=2ms service=4ms status=200 bytes=228
2015-07-06T20:20:17.282767+00:00 app[web.1]: Started POST "/u/users/password" for 98.117.13.138 at 2015-07-06 20:20:17 +0000
2015-07-06T20:20:17.298525+00:00 app[web.1]:   User Load (1.7ms)  SELECT  "users".* FROM "users" WHERE "users"."email" = $1  ORDER BY "users"."id" ASC LIMIT 1  [["email", "baughmann1@gmail.com"]]
2015-07-06T20:20:17.286220+00:00 app[web.1]: Processing by Devise::PasswordsController#create as HTML
2015-07-06T20:20:17.283508+00:00 app[web.1]: Cannot render console from 98.117.13.138! Allowed networks: 98.117.13.138, 127.0.0.0/127.255.255.255, ::1
2015-07-06T20:20:17.286465+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"Vofz0oUxwctFlOplx61cSineCElHOl0KJNeQv52gyMRXta4EXhLy7agZGrEWHpNOTSw6BNNdLocBqd11yp92gQ==", "user"=>{"email"=>"baughmann1@gmail.com"}, "commit"=>"Send me reset password instructions"}
2015-07-06T20:20:17.560246+00:00 app[web.1]:   User Load (1.3ms)  SELECT  "users".* FROM "users" WHERE "users"."reset_password_token" = $1  ORDER BY "users"."id" ASC LIMIT 1  [["reset_password_token", "e80068946760c81716c8afee3cb57a6c961af0c4c47f7772bbf5236ff8b282d8"]]
2015-07-06T20:20:17.566867+00:00 app[web.1]:   SQL (1.3ms)  UPDATE "users" SET "reset_password_token" = $1, "reset_password_sent_at" = $2, "updated_at" = $3 WHERE "users"."id" = $4  [["reset_password_token", "e80068946760c81716c8afee3cb57a6c961af0c4c47f7772bbf5236ff8b282d8"], ["reset_password_sent_at", "2015-07-06 20:20:17.560703"], ["updated_at", "2015-07-06 20:20:17.562609"], ["id", 1]]
2015-07-06T20:20:17.581314+00:00 app[web.1]:   Rendered devise/mailer/reset_password_instructions.html.erb (1.0ms)
2015-07-06T20:20:17.562268+00:00 app[web.1]:    (1.0ms)  BEGIN
2015-07-06T20:20:17.569810+00:00 app[web.1]:    (2.1ms)  COMMIT
2015-07-06T20:20:17.759415+00:00 app[web.1]: 
2015-07-06T20:20:17.759424+00:00 app[web.1]: Devise::Mailer#reset_password_instructions: processed outbound mail in 186.4ms
2015-07-06T20:20:17.960140+00:00 heroku[router]: at=info method=POST path="/u/users/password" host=qwestera.herokuapp.com request_id=39d72953-5e4d-4851-8202-2e18119f918a fwd="98.117.13.138" dyno=web.1 connect=0ms service=684ms status=302 bytes=1188
2015-07-06T20:20:17.996691+00:00 heroku[router]: at=info method=GET path="/u/users/sign_in" host=qwestera.herokuapp.com request_id=93dfa4e6-ba11-4aa3-925b-85392814217c fwd="98.117.13.138" dyno=web.1 connect=2ms service=19ms status=200 bytes=4318
2015-07-06T20:20:17.952283+00:00 app[web.1]: 
2015-07-06T20:20:17.952298+00:00 app[web.1]: From: noreply@qwesteraherokuapp.com
2015-07-06T20:20:17.952289+00:00 app[web.1]: Sent mail to baughmann1@gmail.com (192.7ms)
2015-07-06T20:20:17.952296+00:00 app[web.1]: Date: Mon, 06 Jul 2015 20:20:17 +0000
2015-07-06T20:20:17.952306+00:00 app[web.1]: Mime-Version: 1.0
2015-07-06T20:20:17.952299+00:00 app[web.1]: Reply-To: noreply@qwesteraherokuapp.com
2015-07-06T20:20:17.952303+00:00 app[web.1]: Message-ID: <559ae301ba679_33fac020282ec154d7@07e16014-4ccc-4f8a-863c-f2004129eb1c.mail>
2015-07-06T20:20:17.952304+00:00 app[web.1]: Subject: Reset password instructions
2015-07-06T20:20:17.952307+00:00 app[web.1]: Content-Type: text/html;
2015-07-06T20:20:17.952310+00:00 app[web.1]: Content-Transfer-Encoding: 7bit
2015-07-06T20:20:17.952309+00:00 app[web.1]:  charset=UTF-8
2015-07-06T20:20:17.952314+00:00 app[web.1]: 
2015-07-06T20:20:17.952316+00:00 app[web.1]: <p>Someone has requested a link to change your password. You can do this through the link below.</p>
2015-07-06T20:20:17.952301+00:00 app[web.1]: To: baughmann1@gmail.com
2015-07-06T20:20:17.952311+00:00 app[web.1]: 
2015-07-06T20:20:17.952313+00:00 app[web.1]: <p>Hello baughmann1@gmail.com!</p>
2015-07-06T20:20:17.952317+00:00 app[web.1]: 
2015-07-06T20:20:17.952321+00:00 app[web.1]: <p>If you didn't request this, please ignore this email.</p>
2015-07-06T20:20:17.952319+00:00 app[web.1]: <p><a href="http://qwestera.herokuapp.com/u/users/password/edit?reset_password_token=g71TUgKqMsqju1zMr4Jz">Change my password</a></p>
2015-07-06T20:20:17.952320+00:00 app[web.1]: 
2015-07-06T20:20:17.952324+00:00 app[web.1]: 
2015-07-06T20:20:17.952323+00:00 app[web.1]: <p>Your password won't change until you access the link above and create a new one.</p>
2015-07-06T20:20:17.982666+00:00 app[web.1]: Started GET "/u/users/sign_in" for 98.117.13.138 at 2015-07-06 20:20:17 +0000
2015-07-06T20:20:17.986717+00:00 app[web.1]: Processing by Devise::SessionsController#new as HTML
2015-07-06T20:20:17.956543+00:00 app[web.1]: Redirected to http://qwestera.herokuapp.com/u/users/sign_in
2015-07-06T20:20:17.956688+00:00 app[web.1]: Completed 302 Found in 670ms (ActiveRecord: 8.6ms)
2015-07-06T20:20:17.983132+00:00 app[web.1]: Cannot render console from 98.117.13.138! Allowed networks: 98.117.13.138, 127.0.0.0/127.255.255.255, ::1
2015-07-06T20:20:17.994017+00:00 app[web.1]:   Rendered devise/shared/_links.html.erb (0.5ms)
2015-07-06T20:20:17.994076+00:00 app[web.1]:   Rendered devise/sessions/new.html.erb within layouts/application (3.4ms)
2015-07-06T20:20:17.995516+00:00 app[web.1]: Completed 200 OK in 9ms (Views: 6.3ms | ActiveRecord: 0.0ms)

Heroku的日志說該連接已被阻止。 但是,它還是經歷了。 我還是將config.web_console.whitelisted_ips = '98.117.13.138'application.rb移到了production.rb

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM