Ray's Blog

Saturday, August 23, 2008

Real Estate "Bubble"

Mark Perry's blog, CARPE DIEM, has always been one of my favorites. He has a great post today on the gloom, doom and pessimism over the Real Estate Bubble Burst potentially causing us problems to the degree that Japan suffered after their own bursted bubble back in the 1990's.

Labels:

Friday, July 11, 2008

Adventures in proxying...

I recently had a request at work to set up an additional virtualhost on one of the reverse proxy servers to proxy in an application for testing. Unfortunately all the links need to be "de-internalized" in order for the site to be of any use to anyone on the outside world.

Having looked into doing this in the past a bit with Sharepoint, I had come across mod_proxy_html and decided it sounded like a great solution to the problem. Wellll, it almost was. :-) After getting a package together for RHEL5 (and subsequently submitting it to EPEL) I was able to get a seemingly working configuration going pretty quickly. However, it soon became obvious that mod_proxy_html likes to actually modify the HTML instead of simply replacing the text you tell it to. It does its best to generate "correct" (W3C compliant) HTML/4.01 or XHTML. You can specify transitional or not, but the end result was that the code that came out did not look like the code as the developers had written it. The side effect of this was the code looking right on Firefox and wrong in IE, or the flash not loading correctly in one browser, and so on and so on, depending on which docstring we chose for the module to convert to. Good fun. To be fair to the module, the HTML was not valid W3C code, and really should have been tweaked, but in the end all the back and forth just made me start looking for another solution that tried to be a little less "smart".

In any case, for comparison's sake, here is the mod_proxy_html configuration I came up with that almost worked:

ProxyRequests off
ProxyPreserveHost off

# We want to redirect people who request / to /index.map
RewriteEngine On
RewriteRule ^/$ /index.map [R]

# Turn the following to "On" for debugging (and then watch error_log)
ProxyHTMLMeta Off
ProxyHTMLLogVerbose on

ProxyHTMLExtended On
ProxyHTMLFixups reset
# If we don't set this, XHTML is used and things look funky in IE.
ProxyHTMLDoctype HTML Legacy

# Custom links for use with mod_proxy_html (a href is probably redundant)
ProxyHTMLLinks input value
ProxyHTMLLinks a href
ProxyHTMLLinks script src

SetOutputFilter proxy-html
RequestHeader unset Accept-Encoding

# Passing this twice to handle multiple occurences of the string in a URL.
# We also need to use POSIX regular expressions or matching fails miserably.
ProxyHTMLURLMap (.*)http://internal.domain.com:8080/apppath(/?.*) $1http://external.domain.com$2 [R,x,l,e,c]
ProxyHTMLURLMap (.*)http://internal.domain.com:8080/apppath(/?.*) $1http://external.domain.com$2 [R,x,l,e,c]
ProxyHTMLURLMap /apppath/ /
ProxyHTMLURLMap /apppath /

# This will rewrite requests into the base directory, but nothing beneath.
# We'll explicitly proxy those later. I don't know of a way to do this with
# so mod_rewrite to the rescue!
RewriteRule ^/favicon.ico$ http://internal.domain.com:8080/favicon.ico [P,L]
RewriteRule ^/([^/]*)$ http://internal.domain.com:8080/apppath/$1 [P,L]



Anyways, after a lot of tinkering and troubleshooting, I began thinking maybe I could set things up to do the HTML "fixes" differently based on what type of browser was accessing the page. Then I smacked myself upside the head for even considering that route. This was becoming way more work than it should be!

I set out to look for a better solution, and stumbled across mod_sed -- released by Sun recently under the Apache license. This also sounded perfect! The developer had posted a lengthy thread about it in the Apache Development mailing list which I read through to see how stable this was -- it sounded perfect. After perusing through the thread however, I realized that lo and behold, Apache 2.2.7 already had something I could make use of -- mod_substitute! Now, RHEL 5 includes only Apache 2.2.3, but fortunately we had built our own RPM of Apache based on the Fedora RPM's and we were at 2.2.9. I quickly loaded up the module into my config and came up with the following:

ProxyRequests off
ProxyPreserveHost off

# We want to redirect people who request / to /index.map
RewriteEngine On
RewriteRule ^/$ /index.map [R]

AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|internal.domain.com:8080/apppath|external.domain.com|n"
Substitute "s|/apppath/|/|n"

# This will rewrite requests into the base directory, but nothing beneath.
# We'll explicitly proxy those later. I don't know of a way to do this with
# so mod_rewrite to the rescue!
RewriteRule ^/favicon.ico$ http://internal.domain.com:8080/favicon.ico [P,L]
RewriteRule ^/([^/]*)$ http://internal.domain.com:8080/apppath/$1 [P,L]



Short, sweet and to the point.

I would have liked to give mod_sed a try and gotten it packaged up for Fedora and EPEL, but the above worked perfectly. The application now works as it's supposed to, and the developers don't have to muck with their HTML.

Labels: , , ,

Saturday, July 5, 2008

Just finished reading...

Sorry, it's been a long time since I've updated anything here. I've got a lot of technical stuff I've been meaning to post, but just haven't gotten around to it.

Anyways, I just finished reading My Grandfather's Son, an autobiography of Clarence Thomas' life up until his confirmation to the US Supreme Court. I only vaguely remember the hoopla surrounding his confirmation hearing, but the details of that ordeal made up only a small part of the book. Clarence's life and experiences almost make him an anti-hero in my mind (which isn't a bad thing). The ups and down, struggles, wrong decisions, financial hardships and the political maze he found himself trapped in honestly made it hard for me to understand what kept him going. In the end, he was able to draw much strength from the strict but love-motivated upbringing his grandparents had given him, and of course, from his faith. Clarence also managed to bring out the great sense of optimism and pride he felt in his country -- thanks in no small part to the many amazing people he met and encountered along the way -- people who would later come to his defense when he needed it most. I came away from the book very glad to have a person of such character and ethic as Clarence Thomas serving on the Supreme Court.

Labels:

Thursday, June 5, 2008

NBA Finals Game 1

Nice win by the Celts tonight. I just about turned the TV off in disgust after Pierce went down -- I was sure he'd torn his ACL there; and what was the point of even watching the rest of the series? Sure glad I kept the TV on though. Pierce has always been one of my favorite players ever since he was the only Team USA player with any cojones or skill in the World Championships debacle from a few years back.

Anyways, Celts better be ready for Game 2, you know Kobe's not going to play as poorly as he did tonight twice in a row.

Labels:

Monday, June 2, 2008

Hey Vole...

Write your cover letter!

Sunday, June 1, 2008

Just watched...

I just watched Garden State, which for some reason I'd never gotten around to seeing before. It reminded me a little of Beautiful Girls and oddly enough both movies have Natalie Portman in them.

Anyways, I liked it. Good music too.

Labels:

Argh!

So my libyahoo2 package was finally approved for inclusion into Fedora. Branches were set up and I was ready to go; should be simple right? Not...

As soon as I imported my package I found out it wouldn't build in Fedora 9 or Fedora rawhide (Koji told me this). An examination of the logs showed some weird errors accessing a hostent struct. Upon examination of the source it seems that the Fedora 9 and later glibc headers have slightly changed the hostent struct. The old functionality is still available if your code is build using the _GNU_SOURCE define. D'oh!

I tested this and the code built find if I added -D_GNU_SOURCE to my Makefile. But what was the right way to get this into Fedora? I either had to make a patch for this against the libyahoo2 0.7.6 sources or get upstream to change this for me. Since I recently received access to libyahoo2 upstream I chose the latter.

The "right" way to do this seems to be to modify the configure.ac file to include a simple macro:

AC_GNU_SOURCE

So, with this completed, I proceeded to release libyahoo2 0.7.6.1. Which I'd totally forgotten how to do properly so this time I wrote up instructions in my wiki so next time I'd remember.

Finally I went to rebuild my RPM with the new version of libyahoo2. Bah, still fails! After more tinkering in my own mock setups I realized I needed to add a couple BuildRequires for glib2-devel and pkgconfig. I sent my changes to the Fedora CVS server and ran make build again. Failure once more. Seemingly on the same error... apparently Koji must cache based on tags. So I bumped the release version up by 1, re-tagged and rebuilt. Now everything works fine!

What an ordeal. :-)

Labels: ,