The ones I've done were for a previous employer, so I don't have access, so
the stuff below is from memory and untested, but here's a relevant
documentation reference:
  http://httpd.apache.org/docs/current/rewrite/flags.html#flag_p
See particularly the performance warning and maybe learn to use ProxyPass
or ProxyPassMatch instead of the stuff below.

<VirtualHost ... >
    ...
    RewriteEngine On
    RewriteRule /(.*) http://localhost:8000/$1 [P]
    ...
</VirtualHost>

(and please don't take my ellipses (is that the correct plural?) literally.)

The trick is the P flag at the end, which you can read about in the docs
referenced above.  Of course replace 8000 with whatever port your gunicorn
or secondary apache or nginx is listening on (but you can test with
runserver).  The square brackets are literal and required.

If you're not used to rewrite espressions, the first argument is a regular
expression matched against the path part of the request, where .* matches
any number of unspecified characters, and the parentheses "capture" a part
of the path (everything after the leading slash).  This capture begins with
the FIRST open parenthesis in the pattern, so it is available as $1 in the
the second argument, which builds the URL to which we are proxying.  (If
you actually need parentheses in the regular expression, you escape them
with backslash.)

Good luck, Bill

On Fri, Mar 22, 2013 at 1:01 PM, Tim Walzer <modusoperandip...@gmail.com>wrote:

> I have both mod_rewrite and mod_proxy available to me.
>
> Also, the server is running nginx which seems to be the preferred way of
> running gunicorn, but I am having trouble getting the nginx config to play
> nice.
>
> Would you be able to provide a sample of your reverse proxy config and
> maybe that will help me see what I'm doing wrong?
>
> Thanks.
>
> On Thursday, March 21, 2013 11:42:49 AM UTC-6, ke1g wrote:
>
>> Have you considered a reverse proxy to something like gunicorn?
>>
>> The way that I know how to do this involves mod_rewrite - I don't know of
>> of the top of my head whether it also requires mod_proxy.  Are these
>> available to you.  I understand that gunicorn is to be preferred to
>> fastcgi, which I haven't used.  I haven't actually set up gunicorn, but
>> have done reverse proxy configuration for it (a skill acquired while
>> suffering under plone).
>>
>> Another approach is your own separate Apache build, assuming you have
>> development tools and either the ability to run this in place of the
>> provided apache or the ability to proxy, as above, but this time to your
>> private Apache.
>>
>> Still, if its true that the best these guys can provide is python2.4 and
>> mod_python, maybe it is time to switch.  I'm pretty happy with my linode.
>> For shared hosting I've deployed a lot of sites to webfaction, and have no
>> complaints.  EC2, if I recall, is a bit dear, but you can roll your own
>> distro for it, if necessary.  There's a big wonderful world out there.
>>
>> Bill
>>
>> On Thu, Mar 21, 2013 at 10:38 AM, Tim Walzer <modusope...@gmail.com>wrote:
>>
>>> Thats what I was afraid of.  Unfortunately Media Temple DVs come
>>> pre-installed with Plesk which in turn comes pre-installed with weird
>>> versions of different software packages, none of which are mod_wsgi.  At
>>> this point I have not figured out a way to install mod_wsgi without
>>> breaking the entire thing.  Maybe its time to move on to a different host.
>>>
>>> On Thursday, March 14, 2013 3:37:22 PM UTC-6, Tim Walzer wrote:
>>>>
>>>> I am currently trying to install Django on a Mediatemple DV (4.0)
>>>> server and have the installation be within a virtualenv.  The django app
>>>> will be run from a subdomain, *parts.domain.com*, while the root
>>>> domain *domain.com* is serving a wordpress site.
>>>>
>>>> I have django installed inside the virtualenv at */var/www/vhosts/
>>>> domain.com/parts/env/* The virtual environment is *'env'.  *The server
>>>> is running python 2.4.3, but I needed at least 2.6, so I installed 2.6
>>>> inside the virtual env and that worked perfectly for setting up the initial
>>>> django site.  Now the problem comes with the running of django.
>>>>
>>>> I created a vhost.conf file under */var/www/vhosts/parts.do
>>>> main.com/conf*
>>>> *
>>>> *
>>>>     <Location "/">
>>>>        SetHandler python-program
>>>>         PythonPath 
>>>> "['/var/www/vhosts/domain.com/****parts/env/bin<http://domain.com/parts/env/bin>',
>>>> '/var/www/vhosts/domain.com/**pa**rts/env/store<http://domain.com/parts/env/store>']
>>>> + sys.path"
>>>>         PythonHandler virtualproject
>>>>         SetEnv DJANGO_SETTINGS_MODULE store.settings
>>>>     </Location>
>>>>
>>>>  The path to virtualproject, referenced in the PythonHandler line, is *
>>>> /var/www/vhosts/domain.com/parts/env/bin/virtualproject.py.  *
>>>>
>>>> The contents of that file are:
>>>>
>>>> *activate_this = '/var/www/vhosts/domain.com/pa
>>>> rts/env/bin/activate_this.py'*
>>>> *execfile(activate_this, dict(__file__=activate_this))*
>>>> *
>>>> *
>>>> *from django.core.handlers.modpython import handler*
>>>> *
>>>> *
>>>> The activate_this.py file is the one that comes with the virtualenv
>>>> installation
>>>>
>>>> When I go to the site *parts.domain.com*, I get the following error in
>>>> the apache logs:
>>>>
>>>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler
>>>> virtualproject: Traceback (most recent call last):
>>>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler
>>>> virtualproject:   File "/usr/lib64/python2.4/site-**pac**
>>>> kages/mod_python/apache.py"**, line 287, in HandlerDispatch\n
>>>>  log=debug)
>>>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler
>>>> virtualproject:   File "/usr/lib64/python2.4/site-**pac**
>>>> kages/mod_python/apache.py"**, line 464, in import_module\n    module
>>>> = imp.load_module(mname, f, p, d)
>>>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler
>>>> virtualproject:   File "/var/www/vhosts/domain.com/**pa**
>>>> rts/env/bin/virtualproject.**py<http://domain.com/parts/env/bin/virtualproject.py>
>>>> "**, line 4, in ?\n    from django.core.handlers.modpython import
>>>> handler
>>>> [Thu Mar 14 17:29:45 2013] [error] [client ] PythonHandler
>>>> virtualproject: ImportError: No module named django.core.handlers.modpython
>>>>
>>>> I can only think that this is happening because apache is attempting to
>>>> use the system default python2.4 instead of the one in my virtualenv where
>>>> django is installed.  How do I fix this?
>>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to