Rails 3 application : RoutingError like : /stripe/hook - ruby-on-rails-3

I am not understanding from where I am getting these requests.
below I have pasted the error log, please have a look :
Started POST "/stripe/hook" for 127.0.0.1 at 2013-07-12 12:20:33 +0530
ActionController::RoutingError (No route matches [POST] "/stripe/hook"):
Rendered /usr/local/rvm/gems/ruby-1.9.2-p320#aq/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.7ms)
Started POST "/callbacks/geo/berkeley/" for 127.0.0.1 at 2013-07-12 12:20:34 +0530
ActionController::RoutingError (No route matches [POST] "/callbacks/geo/berkeley"):
Rendered /usr/local/rvm/gems/ruby-1.9.2-p320#aq/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.7ms)
Started POST "/callbacks/geo/berkeley/" for 127.0.0.1 at 2013-07-12 12:20:34 +0530
ActionController::RoutingError (No route matches [POST] "/callbacks/geo/berkeley"):
Rendered /usr/local/rvm/gems/ruby-1.9.2-p320#aq/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.7ms)
Started POST "/upload/pandastatus" for 127.0.0.1 at 2013-07-12 12:20:38 +0530
ActionController::RoutingError (No route matches [POST] "/upload/pandastatus"):
Rendered /usr/local/rvm/gems/ruby-1.9.2-p320#aq/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (1.2ms)
Started POST "/upload/pandastatus" for 127.0.0.1 at 2013-07-12 12:20:40 +0530
ActionController::RoutingError (No route matches [POST] "/upload/pandastatus"):
Rendered /usr/local/rvm/gems/ruby-1.9.2-p320#aq/gems/actionpack-3.1.0/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.6ms)
Started POST "/upload/pandastatus" for 127.0.0.1 at 2013-07-12 12:20:45 +0530
ActionController::RoutingError (No route matches [POST] "/upload/pandastatus"):

Someone is scanning the localtunnel subdomains for open hooks. These request are coming from localtunel connection with localtunel service

You may be missing a necessary method in your controller related to your upload -- that is, some sort of create or upload method. Be sure to run rake routes as well.

Related

Vue Site Running in S3 returning 404 but still loading

I have a site running in Vue2 and for the user everything seems to work right, however google doesn't seem to agree and shows most of my site as having 404 errors. I verified that when using a direct url on the site for example:
hptts://example.com/example
The page will load fine in the browser, but the console will immediately report a 404, but then load the content normally.
This means that lighthouse and google search console all show my page as a 404.
The site is hosted in AWS S3 as a static site, and I have index.html as the entry point and as the error location. I have user facing errors coming from Vue Router that work fine.
Any thoughts on what could be causing the 404 in the console and how to resolve it?
A real world example of this is https://lattecalories.com/brewing/starbucks-holiday-flavors-a-guide-for-2021
The HTTP 404 is the status code from the server itself saying that the URL is unknown, the thing is, when you have services nested into other ones such as S3, Cloudflare, and other APIs, you might end up having a perfectly good website with a 404 on top.
From a quick trace on your side, I seem to have found what is triggering this inside Amazon.
Look at this output:
HTTP/1.1 404
date: Sat, 29 Jan 2022 17:49:30 GMT
content-type: text/html
display: staticcontent_sol
expires: Fri, 28 Jan 2022 17:49:30 GMT
last-modified: Sat, 29 Jan 2022 13:07:11 GMT
pagespeed: off
response: 404
vary: Accept-Encoding
vary: "X-Clacks-Overhead":"GNU,Terry,Pratchett",User-Agent,Origin,Accept-Encoding
x-amz-error-code: NoSuchKey
x-amz-error-detail-key: brewing/starbucks-holiday-flavors-a-guide-for-2021
x-amz-error-message: The specified key does not exist.
x-amz-id-2: NnQCklbWF34u0C188TUsd6FrlA7IHcfjh3lSNqU7eX6MLSKG5yxM/9AsgeAlaCqCZFrPzOs7JNk=
x-amz-request-id: AYR2Z1Q5H45D1B6V
x-ezoic-cdn: Miss
x-middleton-display: staticcontent_sol
x-middleton-response: 404
x-origin-cache-control:
x-sol: pub_site
cf-cache-status: DYNAMIC
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=CWwatL5unsl0K3Tt8iy4Sv3b6zcy54UMMaruLGh5hVyFcbMi2qEo13mxbofVr5JTkOOM2HGwFvWweklpm2inUMS279wCx0uJhKzfqR16JU%2BpIXZSrqR3YNGXjr%2FWxc%2BnLpgCmVn1ZJAc5zxYVWmSBg%3D%3D"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 6d544c288d2dec19-ATL
content-encoding: gzip
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
Those NoSuchKey, I also notice that when I try to hit that site on an invalid URL the site still loads instead of your 404 page, this means the distribution method is wrong and you might not be pointing correctly to the S3 URLs.
I would just create a new download distribution to your S3 URLs, that would fix this, this is a mapping issue. When you are running this on defaults this is pretty common.
Check out this answer here: "The specified key does not exist" for VueJS app deployed on deployed on S3 with CloudFront
Based on the answer by #Kram, this error information is highly relevant (I'm getting the same error in my site):
x-amz-error-code: NoSuchKey
x-amz-error-detail-key: brewing/starbucks-holiday-flavors-a-guide-for-2021
x-amz-error-message: The specified key does not exist.
It may fix it if you change CloudFront to respond with 200 OK (as described in the above URL).
The nature of the error is that S3 is trying to load the URL domain.com/brewing/starbucks-holiday-flavors-a-guide-for-2021 but that location doesnt exist in the bucket.
The fix is to redirect to /index.html to allow vue-router to resolve the URL.
I'm currently suffering this error in my Vue3 application in S3, but we aren't using CloudFront. I added the error page as index.html but it didn't fix the error. The website loads properly but it throws a 404 into the console everytime you reload the page. We're going to simply ignore the error for now and we will add CloudFront later. It's just a dev environment for now.

Apache: Response code not 2xx (302) response in bench marking

What is the meaning of
WARNING: Response code not 2xx (302)
LOG: header received: HTTP/1.1 302
I found that in Apache bench marking.
What does it mean?

Production Rails App - Strange redirect to external sites

I've just launched my first Rails 3.2.6 application to a production server. When someone goes to the home page this is handled by my IndexController and depending on the type of user logged in it might send it to an alternative URL.
Slightly simplified code example of what I have is this:
def index
path = new_user_session_url #default path
if current_user
path = users_admin_index_path #admin path
end
redirect_to path, :notice => flash[:notice], :alert => flash[:alert]
end
What I'm confused at, is I've been monitoring the logs for issues and it appears the redirect is going to random sites in Brazil for two IP addresses. Is this something that I should be worried about? Any information on helping me understand what's going on here would be very much appreciated.
See the log extract below where in the "Redirected to" URL, the domain is getting changed from what my site is to www.bradesco.com.br, www.bb.com.br or www.itau.com.br.
No one has reported any issues on the site, but I just wanted to try and understand this a little better.
Log Extract
Started GET "/" for 65.111.177.188 at 2012-08-10 00:20:10 -0400
Processing by Home::IndexController#index as HTML
Redirected to http://www.itau.com.br/home
Completed 302 Found in 2ms (ActiveRecord: 0.0ms)
Started GET "/" for 65.111.177.188 at 2012-08-10 00:20:10 -0400
Processing by Home::IndexController#index as HTML
Redirected to http://www.bradesco.com.br/home
Completed 302 Found in 1ms (ActiveRecord: 0.0ms)
Started GET "/" for 65.111.177.188 at 2012-08-10 00:20:10 -0400
Processing by Home::IndexController#index as HTML
Redirected to http://www.bb.com.br/home
Completed 302 Found in 1ms (ActiveRecord: 0.0ms)
Started GET "/" for 64.251.28.71 at 2012-08-09 22:00:20 -0400
Processing by Home::IndexController#index as HTML
Redirected to http://www.bradesco.com.br/home
Completed 302 Found in 1ms (ActiveRecord: 0.0ms)
I'm seeing the same thing with one of my Rails staging servers. I think the issue is that you need to reject all traffic that isn't for the expected domains.
Something like this in your nginx setup ( if you're using nginx ):
http://nginx.org/en/docs/http/server_names.html
server {
listen 80 default_server;
server_name _;
return 444;
}
Not sure what the point of this traffic is? Some sort of round-about new way of using someone else's Rails app as a phishing site, while sniffing network traffic? There seems to be too many variables for that to be an effective technique.

how should I go about making all Devise paths use https?

Related: Rails 3 SSL routing redirects from https to http (unfortunately didn't work).
Duplicate, but the answer didn't work for me: setting up ssl on devise
I have a web app that's been working fine for a while now but I need to add SSL to the login/edit acct paths. I'm using Devise for authentication. I found an entry in the devise wiki that made the process seem pretty simple, but damn if I can get it to work. The simple part was this:
#in config/environments/production.rb
config.to_prepare { Devise::SessionsController.force_ssl }
config.to_prepare { Devise::RegistrationsController.force_ssl }
And then there's about 25 lines of code in this gist: https://gist.github.com/1040964
I got that to work well enough, but when ever I sign out I get a 301 from the sessions DELETE action that sends me to a GET.
Started DELETE "/users/sign_out" for 98.246.164.160 at 2012-03-02 01:45:42 +0000
[02 Mar 01:45 10886 INFO] Processing by Devise::SessionsController#destroy as HTML
[02 Mar 01:45 10886 INFO] Parameters: {"authenticity_token"=>"fI4VZ4V0Go2Civo3sJz8Dv5/Wtaa90ynaYr+xxx="}
[02 Mar 01:45 10886 DEBUG] Parameters: {"_method"=>"delete", "authenticity_token"=>"fI4VZ4V0Go2Civo3sJz8Dv5/Wtaa90ynaYr+xxxx=", "action"=>"destroy", "controller"=>"devise/sessions"}
[02 Mar 01:45 10886 INFO] Redirected to https://ec2-xx-xx-106-255.us-west-2.compute.amazonaws.com/users/sign_out
[02 Mar 01:45 10886 INFO] Completed 301 Moved Permanently in 3ms
Started GET "/users/sign_out" for xx.xx.164.160 at 2012-03-02 01:45:42 +0000
[02 Mar 01:45 10886 FATAL]
ActionController::RoutingError (No route matches [GET] "/users/sign_out"):
So I think I need to start over from scratch. What's the simplest way to make any Devise path use https, but the rest of the paths in my app use http? I tried this (from the SO post at the top):
#devise routes
scope :protocol => 'https://', :constraints => { :protocol => 'https://' } do
devise_for :users, :controllers => { :registrations => :registrations }
devise_for :admins
end
But no go. I need a better suggestion.
No answers yet, so here's what I concluded:
Once you access a site via https, don't access it via http until the user signs out (firesheep attack). There's a lot of stuff on Devise in the article linked above that discusses only having https on the sign in / out page. Bad idea.
All you really need is this:
#in config/environments/production.rb
config.to_prepare { Devise::SessionsController.force_ssl }
config.to_prepare { Devise::RegistrationsController.force_ssl }
I had a ton of issues surrounding 'after_sign_in_path' from Devise. It turns out that after_sign_out_path_for is expecting a path to be returned -- it's not an event, it is asking where the user should be directed. So I returned root_path :protocol => 'http://' and that took care of it.
Try making your whole app use HTTPS by adding:
#in config/environments/production.rb
config.force_ssl = true
I had quite the same problem. Sometimes I sign out fine sometimes I got 301 from DELETE action and redirect to GET. For me this was the problem.
Make sure you use https in all your Devise links (this avoids the force_ssl redirect).
In your routes.rb (only applied in production environment):
scope defaults: (Rails.env.production? ? { protocol: 'https' } : {}) do
devise_for :users
end
Now in your application use:
destroy_user_session_url # use _url instead of _path so the protocol is added!
Now your logout / sign out link (and other devise links) will point directly to https. The force_ssl rewrite from HTTP DELETE to HTTPS GET is avoided. It all works :)

apache2 + Passenger3 + Rails3 routing problem

Having a problem with passenger 3
in routes.rb i have
match 'main/subgroups/:id' => 'main#subgroups'
And in access_log file
"GET /main/subgroups/Arts HTTP/1.1" 304 - "-"
"GET /main/subgroups/Arts%2FCrafts%2FNeedlework HTTP/1.1" 404 323 "-"
As I understand Apache does not pass the second request to passenger.
What should I change in httpd.conf?
The problem is that the second URL is not matching the route since your 'id' field has forward slashes in it, which is a delimiter for rails routes.
In order to make this work try changing your route to (Note the * instead of the : on id):
match 'main/subgroups/*id' => 'main#subgroups'
That should ensure that everything after main/subgroups is set into params[:id] regardless of it's contents.