How to use rails bundler behind a authenticated proxy? - ruby-on-rails

I am new to ruby and getting started to learn ruby on rails.
I am behind authenticated proxy network.
I researched on the internet, however the answers didn't work for me.
Password has special characters
I have exported http_proxy in ruby shell
export http_proxy=ht tp://foo:b\#r\#192.168.1.1:8080
When issued bundle update I get below error
:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/uri/generic.rb:213:in `initialize': the scheme http does not accept registry part: foo:b#r#192.168.1.1:8080 (or bad hostname?) (URI::InvalidURIError)
from c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/uri/http.rb:84:in `initialize'
from c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/uri/common.rb:214:in `new'
from c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/uri/common.rb:214:in `parse'
I tried remove \ before 2 in both places, but didn't work.
I have put this content in .gemrc file in the folder where I create first_app
Yet didn't work.
Anyone who has used Rails behind authenticated proxy, please help me?

Related

How can I build an SSL cert/chain for the Rails pg gem to fix PG::ConnectionBad (SSL SYSCALL error: Connection reset by peer (0x00002746/10054))

My company seems to have recently made some sort of change to the Cisco Endpoint Ark blah blah blah setup on our corporate Windows laptops, and the SSL configuration has killed the ability of one of my programs to talk to a Postgres server hosted at Azure. E.g.,
C:\Users\xxxxx\Projects\stuff_and_things>rails c
Loading production environment (Rails 6.0.3.4)
irb(main):001:0> User.first
Traceback (most recent call last):
1: from (irb):1
PG::ConnectionBad (SSL SYSCALL error: Connection reset by peer (0x00002746/10054))
For 3 years, just specifying sslmode: require has been all I've needed for the pg gem to connect to my database server. I've played with the various sslmode and sslrootcert keywords in my database.yml file, but nothing I've tried has worked, and I'm not getting any hints or error messages about what the problem actually is. Rails can't get far enough in this process to even give me any messages in the log.
From other things I've read, I think I need to build a new, single cert that includes the whole chain of trust in one file, and specify that as root.crt, but I can't find any reference about how to do that. I know Rails is "old and busted" now, so finding any tips about this has been really difficult.
Does anyone have any clearer insight on how I could make the Rails pg gem happy again, or at least any way I could get better error messages from the process?
I recalled that I've had to work around this kind of SSL issue on our laptops before, to get bundler working. Thanks to that pointer to RubyInstaller's SSL FAQ, I got that to work after adding Cisco's Umbrella root and 2048 cert .pem's to the right place, and run a script that comes with RubyInstaller to rehash the cert stack. Notably, I was helped in this process through bundler's error messages, which told me that I needed those particular certs to satisfy the chain of trust.
Weighing in at 240KB, I finally realized that the .pem file that RubyInstaller's script had produced -- which is still keeping bundler happy -- was, in fact, the complete trust chain I needed to make the pg gem happy as well, so, in my database.yml, I've used:
sslmode: verify-full
sslrootcert: C:\Ruby25-x64\ssl\cert.pem
And this seems to have made Rails happy again. Now I have to figure out how I'm going to keep these settings separate between my Windows and Linux machines hitting the same production server...

Unable to run rails commands due to invalid URI

Whenever I try to run foreman run rails server I receive the following error message from rails:
Absolute URI missing hierarchical segment: 'http://:9200' (Addressable::URI::InvalidURIError).
I realize that 'http://:9200' is an invalid URL, but part of the problem is that not even sure why my absolute URI is 'http://:9200'.
I looked through the Addressable gem's documentation, but I didn't see anything relevant that would solve my issue.
This isn't my project originally, but is a project I pulled from github, so there's a lot going on that I'm not aware of. But I do know that it uses the Addressable gem as well as foreman. I'm just trying to run the server locally.
Any ideas?
It turns out that this was a problem with ElasticSearch. The ElasticSearch_URL environment variable was not set, and that led to an invalid URI.
This problem was identified by the numbers ":9200" in the URL, which is the default port that ElasticSearch uses.

Rails Production: Premature end of script headers

I'm attempting to host my rails app on a vps. The issue that I'm running into is when I try to navigate to my rails app, I get the following error message:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
When I check out the virtual server's error log it tells me the following:
Premature end of script headers:
And sometimes that's followed with a feed or a contact or a referer: myurl.com/ or nothing at all.
I've seen plenty of posts regarding this error messages elsewhere but none so far have resolved the matter. The general consensus seems to be that it likely has to do with the rails environment variable or file.
As this is my first attempt at putting a rails app on a production server, I figure this is plausible. Below is my environment.rb
cat config/environment.rb
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
As for the server, I'm using Ubuntu 12.04 with Webmin/Virtualmin and apache2 with passenger. Ruby 2.1.5p273 was installed using RVM and all gems are up to date.
Any thoughts would be helpful!
Today I was confronted with exactly the same problem. In my case it was the line 'secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>' in config/secrets.yml (but the env variable was not defined on the server). Please, look in §3.3 of http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html.

Phusion Passenger: ArgumentError (invalid byte sequence in US-ASCII)

I am running a small Rails application under Ubuntu 14.04.1, using RVM to manage rubies. I have started using the Phusion Passenger (4.0.48)/nginx package so I can eventually serve multiple Rails applications from the same server (an older Dell laptop) in a low volume production environment. The application uses RSolr to make calls to a SOLR server to get text from old lab notebooks.
When I run the application using WEBrick or the Passenger standalone application server, it works fine. But when I run it under nginx, I get an error when certain text is returned from SOLR:
ArgumentError (invalid byte sequence in US-ASCII):
<internal:prelude>:10:in 'synchronize'
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:74:in 'process_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:141:in 'accept_and_process_next_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:109:in 'main_loop'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:448:in 'block (3 levels) in start_threads'
I assume this is due to non-ASCII text being returned by SOLR to be presented on the display page. Since I don’t get this error when running under WEBrick or the passenger stand-alone server, I assume this is due to some configuration setting(s) related to how Passenger and nginix interact. I've Googled around on this issue, most posts relate to using utf8 in your ruby code, or getting the correct ENV setting, e.g. here, but nothing that seems to address this situation.
Any suggestions on where I should be peeking or troubleshooting, or where I should be changing a configuration setting? Thank you.

Google Visualizations for Rails 3 - uninitialized constant ApplicationHelper::GoogleVisualization

I am using the following gem for Google Visualizations https://github.com/jeremyolliver/gvis
I have followed the instructions for installation and usage on the page but I get the following error:
uninitialized constant ApplicationHelper::GoogleVisualization
How can I correct this error? I think it may be to do with restarting the server or rails but I'm not sure how to do this
Also what is the common plugin/gem or approach to using Google Visualizations with rails 3?
EDIT: I have now restarted my server and get the same error. One thing I noticed in the installation instructions is renaming the directory:
mv vendor/plugins/rails/rails-google-visualization-plugin vendor/plugins/google_visualization
The first line has a sub directory called rails within vendor/plugins, however this is not actually created when the plugin is installed. I am not sure if this is a typo error or not in the installation instructions
It's possible that you just need to restart your server. Open the console with your Mongrel or WEBrick running, and type Ctrl+C, and when it's done exiting, type rails s.

Resources