So I'm trying to make a website for school and I've been following this guys tutorial on how to make a website. But for some reason when I get to lesson 32 and I enter the ec2-user:~/environment/blog $ rails server -b $IP -p $PORT command, the website doesnt run and it says " somenumbersandletters.vfs.cloud9.us-east-2.amazonaws.com refused to connect " with an error. I've followed all the steps correctly (Except for the directory he runs it from, I run it straight from blog instead of environment because it tells me I need to make a new app the other way). I've tried disabling my firewall, I've enabled Cookies and searched the internet for a solution. I am very new to Servers and Coding and any help would be greatly appreciated!
This is my Terminal Log
Answer from https://www.reddit.com/r/aws/comments/cwnbt1/aws_cloud9_server_refuses_to_connect/
Once you start the rails server, click the 'preview' button. When this tells you that it refuses to connect, find the button that looks like two overlapping squares with an arrow to "pop out into a new window." Once it was in a new tab, it worked like a charm.
Hope this helps!
I ran into this issue as well. I could view my rails application when viewing it from within a new tab, but not within the Cloud 9 IDE tab.
If you look in the browser console when viewing through the tab, you will see this error:
Refused to display 'https://xxxxxxxxxxxxxxxxxxxxxxx.vfs.cloud9.xxxxxxxxxxx.amazonaws.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
This error is being caused because you are viewing the rails application through an iFrame via the Cloud 9 IDE. By default to add security and hinder Cross Site Scripting (XSS) attacks, Rails sets SAMEORIGIN for the X-Fram-Options header. This will not allow the rails app to be visible in the Cloud 9 IDE tab using the iFrame.
In order to bypass this, you will need to set this header to use ALLOWALL instead.
NOTE: Only do this within your development environment and never in a production environment. This could open your site up to XSS attacks.
Add the following configuration option to your config/environments/development.rb file:
config.action_dispatch.default_headers = {
'X-Frame-Options' => 'ALLOWALL'
}
After saving the changes, restart your rails server and the application should now be visible within the Cloud 9 IDE tab directly.
Related
I have SAP BTP trial account in which Im trying to run a SAPUI5 application via the SAP Business Application Studio (BAS). I have added nothing fancy to it. Just created one from the one of the many UI5 templates and tried running it from the terminal via the command ui5 serve.
The command does execute without any problems and also provides me with the standard localhost:8080 URL. Im using Firefox since BAS doesn't seem to work with Edge as well as Chrome.
I even get a message popping on the right bottom corner telling me a service is listening to port 8080 with a button that says "open in New Tab" pressing it however does nothing.
Im new to SAP BTP and BAS. Are there more things to configure before running the application? Or perhaps I have to configurate the browser itself? The error message:
I have also had some experience with the Business Application Studio.
You don't work locally here like in VS Code, for example. That's why you can't access it via localhost:8080, but have to use the link that provides the BAS. In this case, something like
port8080-workspaces-....applicationstudio.cloud.sap.
The best thing you can do is to press "Open in new tab" on the screenshot with "A service is listening to port 8080", then you will be redirected to the working link.
Kind regards
Sebastian
I'm new to programming and trying to make changes to a Rails app. I downloaded a forked repo from Github and got it up and running on my local computer after running rake db:migrate (originally got error messages).
I've since made changes to a few HTML files (minor - changed text of a few sentences) in Sublime and saved, but they aren't reflected in browser.
I refreshed the browser and tried restarting the server. I must be missing steps. Any help appreciated, thank you.
There are a few things that could be happening. Most likely, you are getting some browser cache( but you could be getting a network, web server cache as well)
Try reloading the page with ctrl + r ( or cmd + r if you don't like real nix)
Next you could try loading in an incognito window to see if it's a session level issue.
Next you can try restarting your server. In general in development environment there shouldn't a cache set up but maybe you are hitting an issue there.
In my dev config, I have all the caching off. In my dev browser I have all the dns/browser caches disabled.
At the end of the day, you could be modifying the wrong file. Try ack'ing or grepping to see if there are other occurrences of that text in other files. Often there will be multiple header partials or multiple layouts that are similar but not really.
I'm working on implementing omniauth into a Rails project. My problem is that the authentication providers - Twitter, Google, Facebook etc all require me to create an application with a url that limits authentication requests from anywhere other than the url. I need to be able to to test locally but also run code in production, but Facebook for example doesn't allow 2 domains and doesn't allow localhost anyhow.
So what are my options?
At work, we have multiple applications setup for the different environments. On local, add an entry in /etc/hosts (assuming you are on linux) eg: 127.0.0.1 mydomain.local.
On the facebook app setup for the local environment, add this as the url. Most things, except where facebook needs to scrape your site (Like buttons) work.
Here's a blog post with my solution: http://make.bettermistak.es/2012/05/03/how-to-create-a-local-sandbox-facebook-app/
Here's the relevant bit: "Facebook verifies that all requests for your app are coming from the right domain–they don’t allow requests from localhost or 127.0.0.1–and this info can be updated in your apps settings under Hosting URL. Add “local.herokuapp.com” to your Hosting URLs and save this setting. Then edit your /etc/hosts file so that local content is under the domain local.herokuapp.com. This file is hidden, so from the command line enter sudo vi /etc/hosts. (Substitute your favorite editor for vi.) We need to use sudo, because this file is locked. Add the line “127.0.0.1 local.herokuapp.com” below “127.0.0.1 localhost” and save and quit your text editor."
As far as I know, you must sing up two apps for you app.(one for remote side, one for local side)
Fortunately, there is a way to reduce the complication(Assuming you are working on linux):
You can configure you .bash_profile (local machine and remote machine separately):
export YOURAPP_APP_ID="XXXXX"
export YOURAPP_APP_SECRET="XXXXX"
And use ENV['YOURAPP_APP_ID'] and ENV['YOURAPP_APP_SECRET'] in your code.
For example, you can code like this in rails:
config.omniauth :facebook, ENV['YOURAPP_APP_ID'], ENV['YOURAPP_APP_SECRET']
By this way, you can use the same code in both local and remote side. It will be much easier for maintaining.
If you are using Heroku to host your application, you can refer to this page to config the environment variables.
I have created two apps on Facebook one of which i run in sandbox mode for development purposes. Would that be an option for you?
I'm developing a rails app and running the server in the development environment on my local host. I'd like to see the error page that I would see when the app is on the production server, and I go to myapp.com/should_show_error_page so that I can style it. Currently, when I go to a page that should display this kind of error, I get the full exception description and stack traces. Starting the server with RAILS_ENV=production isn't enough unless I go to the page from a different machine. I'd appreciate any help.
Update
Setting config.consider_all_requests_local = true in config/environments/development.rb doesn't do it either
another update
I'm using goalie to generate the error pages, so they're not static.
The easiest way to do this would be to access this through the hostname of your computer. For example, I would test it using http://ryanbigg.local:3000/. To get the hostname, type hostname in your prompt.
Just mirror your production server's configuration. Without knowing what that is, I could not comment further.
Edit public/500.html. Browse to http://localhost:3000/500.html to see what it looks like.
I've installed Rack-Bug for my Rails app, but can't get the panels to appear.
project: http://github.com/brynary/rack-bug
additional instructions: https://github.com/brynary/rack-bug/wiki/security
yet more instructions: Rack Bug Installation issue. Server does not start
(the docs really suck for this one)
From the top:
I added config.middleware.use 'Rack::Bug' to config/environments/development.rb.
I added a file config/initializers/rack_bug.rb containing the following:
require 'rack/bug'
require 'ipaddr'
ActionController::Dispatcher.middleware.use Rack::Bug,
:ip_masks => [IPAddr.new('192.168.2.2')],
:secret_key => 'epT5uCIchlsHCeR9dloOeAPG66PtHd9K8l0q9avitiaA/KUrY7DE52hD4yWY+8z1',
:password => 'password'
(I specified the IP address for my desktop. The app is running on my linux dev server at .2.3)
I went to /rack_bug/bookmarklet.html and dragged the "Toggle Rack::Bug" bookmarklet to my Firefox bookmark toolbar. I loaded a page on my Rails App, clicked the "Toggle Rack::Bug" bookmarklet, typed in the password in the popup box, clicked OK, and the page was reloaded - but with no Rack-Bug panels.
Not sure why it's not working, and there's no irc channel or google group for it.
UPDATE: And the fun keeps on leaving. Still no progress on loading the panels from Firefox on my windows desktop. However, I fired up Firefox on my linux dev server, grabbed the bookmarklet, then went to the home page of my app and clicked on it. Filled in the password, and when it reloaded, got a 500 error. Here are the first four lines from the log output:
Status: 500 Internal Server Error
undefined method `length' for #<Pathname:/home/ofer/src/ssp3>
/usr/lib/ruby/gems/1.8/gems/ruby-openid-2.1.7/lib/openid/extras.rb:3:in `starts_with?'
/home/ofer/src/ssp3/vendor/plugins/rack-bug/lib/rack/bug/panels/sql_panel/query.rb:65:in `filtered_backtrace'
So, I still haven't fixed the first problem, and now I've discovered a second which will still be around even if I fix the first problem. The second error seems to imply that Firefox on the dev server was actually loading the panel when the error hit, which apparently is in the ruby-openid internals.
I feel even more set back than before.
My guess: http://github.com/SamSaffron/rack-bug/commit/16daa41b0ac9513e2d0a2b09ad9941fcb9c5d189
Had the same problem so I wrote that patch, I'll do a pull request
I had the same problem and after fiddling around a bit found that you should reload the page without using the browser cache (i.e. press Ctrl-F5)
Is your Linux development server on the same subnet as your desktop? If it isn't then you need to specify your desktop's IP address as it appears to the server. For example my desktop's IP address is 192.X.X.X but from my production server it appears as 84.X.X.X because it's routed through my ISP's gateway.