Nicolas Alpi

Hi, Salut

Pragmatic web application developer, I enjoy my freelance way of life in my home office every day. I mainly use Ruby based frameworks (Rails / Sinatra / Rack) as my main development arsenal and jQuery is my day to day friend for every piece of client side. Aside from development freedom, I really enjoy the business side of behind freelance, and will soon to release my own personal application. In my free time, I enjoy cooking, runnning and sharing a coffee or a beer with people, so if you're around Bristol, let's be in touch.


Passing env variable to Ruby with Apache

I had a problem last week, while developing tweetcetera. I need to use open-uri to open the twitter search url.

BUT, when I develop/test from from my office, I needed to pass through my corporate proxy. Obviously not when I’m at home, and not on my staging/development server.

For the first days I just manage to remove the proxy config variable in my application.rb and that was ok, but it’s certainly not an elegant solution.

First I wanted to create new environments like development_office and test_office, with specific config files … bullshit.

The solution is pretty easy.

open_uri look at environment variables.
Apache use a file call envvars, to setup these environment variables.

So just edit your envvars file (In your Apache folder), and add your env variable like

export http_proxy=http://mycorporate.proxy.com:8080

Restart apache and it’s ok.

Sweet.


Comments

blog comments powered by Disqus