Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3240548
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:05:53+00:00 2026-05-17T18:05:53+00:00

I have the following: My webserver running on twisted My comet server, aka orbited

  • 0

I have the following:

  1. My webserver running on twisted
  2. My comet server, aka orbited

Note that 1 and 2 are different processes.

Basically, I want 1 and 2 to share the same port. Request that are http://mysite.com/a/b/c should go to the webserver and anything starting with http://mysite.com/orbited/ should go to the orbited server, i.e. (http://mysite.com/orbited/a/b/c => do a request to http://mysite.com:12345/a/b/c and return that).

This is what I have right now:

# Reverse Proxy
class OrbitedResource(Resource):
    isLeaf = True

    def __init__(self, orbited_url='http://127.0.0.1:12345'):
        self.orbited = orbited_url
        Resource.__init__(self)

    def render_GET(self, request):

        def callback(html):
            request.write(html)
            request.finish()

        def errback(failure, *args):
            request.setResponseCode(http.INTERNAL_SERVER_ERROR)
            request.write(failure.getErrorMessage())
            request.finish()

        request.setHeader('Connection', 'close')

        # TODO find cleaner way to do this:
        # Currently request.uri is "/orbited/....", you must trim it
        target_uri = request.uri.replace('/orbited', '') 
        final_uri = self.orbited + target_uri
        print "final_uri is", final_uri

        deferred = getPage(final_uri)
        deferred.addCallbacks(callback, errback)
        return server.NOT_DONE_YET


class SimpleRoutingResource(Resource):
    isLeaf = False

    def __init__(self, wsgiApp):
        Resource.__init__(self)
        self.WSGIApp = wsgiApp
        self.orbitedResource = OrbitedResource()

    def getChild(self, name, request):
        if name == "orbited":
            request.prepath.pop()
            print "Simple request.path is", request.path
            return self.orbitedResource
        else: 
            request.prepath.pop()
            request.postpath.insert(0,name)
            return self.WSGIApp

# Attaching proxy + django 
log_dir = './.log'
if not os.path.exists(log_dir):
    os.makedirs(log_dir)
reactor.listenTCP(DJANGO_PORT, server.Site(SimpleRoutingResource(WSGIRoot), 
        logPath=os.path.join(log_dir, '.django.log')))

Currently this works . However, I see that there’s a class called ReverseProxyProtocol, and I have been doing tried it with the following modification:

class SimpleRoutingResource(Resource):
    isLeaf = False

    def __init__(self, wsgiApp):
        Resource.__init__(self)
        self.WSGIApp = wsgiApp

    def getChild(self, name, request):
        if name == "orbited":
            request.prepath.pop()
            print "Simple request.path is", request.path, name
            return ReverseProxyResource( 'http://localhost', 12345, name )
        else: 
            request.prepath.pop()
            request.postpath.insert(0,name)
            return self.WSGIApp

This is NOT Working. I have inserted a lot of prints into the twisted’s reverseProxyResource class, and I discovered the following:

  1. Given http://mysite.com/orbited/a/b/c
  2. OrbitedResource will keep calling ReverseProxyResource with getChild until c
  3. by the time you get to c, the url is messed up and the client class calling the orbited server will be wrong
  4. I tried setting isLeaf = True in the ReverseProxyResource, but to no avail.

Anybody can point me a more effecient way to write the getPage? Do I really need to use ReverseProxyResource if it’s such a black box in nature?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:05:53+00:00Added an answer on May 17, 2026 at 6:05 pm

    The cleanest way is to put something like nginx in front of both servers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web server that is running PHP 5.3.6 non thread safe (VC9),
Actually I have the following scenario: I want to create an app that will
I have following script that executes all the .reg files in the current directory.
Using the following example I can get a basic web server running but my
I am running Windows 7 on my machine. I have following web browsers installed:
I have the following UDP broadcast listener running as a static component in a
I am running the following code; it is from the Twisted Framework's example list
I'm running a small Zen-Cart shop and I have the following problem. When I'm
I have a Spring application running on the Glassfish Webserver and I'm seeing some
I have two ruby server scripts, powerupserver.rb and outputserver.rb, of the form: require '/Library/WebServer/sample_app/config/environment'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.