Simple Apache Proxying

By  on  

I was recently working with Apache and a service running on Kris Zyp's Persevere project (which is beyond awesome).  Persevere was pushing messages to my application which was running on Apache; the problem was that Persevere and Apache were running on different ports which technically made them cross-domain.  In order to make the server believe the web service was on the same domain/port, I needed to use Apache proxying.  I opened the conf/httpd.conf file and added the following magic to make that possible:

# Proxy requests to /data to persevere
ProxyPass /service http://localhost:8080/Status
ProxyPassReverse /service/ http://localhost:8080/Status
RewriteRule ^/service$ http://localhost:8080/Status$1 [P,L]

Now any reference to the directory "/Status" is proxied to the other port to receive the data!  Apache proxying is a huge boost to your web application if you can trust the other domain/port.

Recent Features

  • By
    Conquering Impostor Syndrome

    Two years ago I documented my struggles with Imposter Syndrome and the response was immense.  I received messages of support and commiseration from new web developers, veteran engineers, and even persons of all experience levels in other professions.  I've even caught myself reading the post...

  • By
    CSS Filters

    CSS filter support recently landed within WebKit nightlies. CSS filters provide a method for modifying the rendering of a basic DOM element, image, or video. CSS filters allow for blurring, warping, and modifying the color intensity of elements. Let's have...

Incredible Demos

  • By
    Create Twitter-Style Dropdowns Using jQuery

    Twitter does some great stuff with JavaScript. What I really appreciate about what they do is that there aren't any epic JS functionalities -- they're all simple touches. One of those simple touches is the "Login" dropdown on their homepage. I've taken...

  • By
    Chris Coyier’s Favorite CodePen Demos IV

    Did you know you can triple-heart things on CodePen? We’ve had that little not-so-hidden feature forever. You can click that little heart button on any Pen (or Project, Collection, or Post) on CodePen to show the creator a little love, but you can click it again...

Discussion

  1. Not getting…. :-(

  2. I don’t remember for sure, but off the top of my head don’t you have to enable the proxy module as well?

  3. That’s one of the best uses for apache proxying I’ve seen! Awesome!

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!