Okay, I'm making a lot of progress. I want to serve Askbot from mysite.com/ask/, and furthermore, I don't want mysite.com/ being handled by WSGI/Django. As far as I can tell, that means I need to have e.g. WSGIScriptAlias /ask ..., as opposed to WSGIScriptAlias / .... Specifically, when I had ASKBOT_URL = 'ask/' and WSGIScriptAlias / ..., mysite.com/wiki/ was getting handled by Django.
I pretty much have it working how I want, after doing the following:
ASKBOT_URL as ''ASKBOT_MEDIA_URL = 'ask/'get_media_url, have it use ASKBOT_MEDIA_URL instead of ASKBOT_URL/upfiles/ to /ask/upfiles/Everything seems to work, except that logging in and logging out takes people to /, not /ask/.
The question: What's the right way to fix this? Am I going about the subdirectory thing all wrong?
Here's the relevant part of my apache config:
#replace with 127.0.0.1 with real IP address
<VirtualHost 123.345.567.789:80>
ServerAdmin admin@mysite.com
DocumentURL /opt/webapps/
ServerName mysite.com
#aliases to serve static media directly
#will probably need adjustment
Alias /ask/m/ /usr/local/lib/python2.6/dist-packages/askbot-0.6.11-py2.6.egg/askbot/skins/
Alias /ask/upfiles/ /opt/webapps/ask/askbot/upfiles/
Alias /ask/admin/media/ /usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/
<DirectoryMatch "/opt/webapps/ask/askbot/skins/([^/]+)/media">
Order deny,allow
Allow from all
</DirectoryMatch>
<Directory "/opt/webapps/ask/askbot/upfiles">
Order deny,allow
Allow from all
</Directory>
#must be a distinct name within your apache configuration
WSGIDaemonProcess askbot2
WSGIProcessGroup askbot2
WSGIScriptAlias /ask /opt/webapps/ask/django.wsgi
#make all admin stuff except media go through secure connection
#<LocationMatch "/admin(?!/media)">
# RewriteEngine on
# RewriteRule /admin(.*)$ https://example.com/admin$1 [L,R=301]
#</LocationMatch>
CustomLog /var/log/apache2/askbot/access_log common
ErrorLog /var/log/apache2/askbot/error_log
LogLevel debug
</VirtualHost>
I got this working by using nginx as a front-end proxy. Here's my nginx config:
upstream askbot {
server localhost:9000;
}
upstream wiki {
server localhost:9001;
}
server {
listen 80;
server_name xxxxx.members.linode.com;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location ~ ^/ask {
access_log /var/log/nginx/askbot_log;
root /opt/webapps/ask/;
proxy_pass http://askbot;
}
location / {
access_log /var/log/nginx/wiki_log;
root /opt/webapps/wiki/;
rewrite ^/wiki/(.*) /$1;
proxy_pass http://wiki;
}
}
The other thing I had to do was update urls.py:
urlpatterns = patterns('',
(r'%s' % settings.ASKBOT_URL, include('askbot.urls')),
(r'^ask/admin/', include(admin.site.urls)),
#(r'^cache/', include('keyedcache.urls')), - broken views disable for now
(r'^ask/settings/', include('askbot.deps.livesettings.urls')),
(r'^ask/robots.txt$', include('robots.urls')),
)
And, as you suggested, I removed the ASKBOT_MEDIA_URL setting.
For completeness, here's my apache config:
<VirtualHost localhost:9000>
ServerAdmin xxxxxxxxx
DocumentRoot /opt/webapps/ask/
ServerName xxxxxxxx
#aliases to serve static media directly
#will probably need adjustment
Alias /ask/m/ /usr/local/lib/python2.6/dist-packages/askbot-0.6.11-py2.6.egg/askbot/skins/
Alias /ask/upfiles/ /opt/webapps/ask/askbot/upfiles/
Alias /ask/admin/media/ /usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/
<DirectoryMatch "/opt/webapps/ask/askbot/skins/([^/]+)/media">
Order deny,allow
Allow from all
</DirectoryMatch>
<Directory "/opt/webapps/ask/askbot/upfiles">
Order deny,allow
Allow from all
</Directory>
#must be a distinct name within your apache configuration
WSGIDaemonProcess askbot2
WSGIProcessGroup askbot2
WSGIScriptAlias / /opt/webapps/ask/django.wsgi
#make all admin stuff except media go through secure connection
#<LocationMatch "/admin(?!/media)">
# RewriteEngine on
# RewriteRule /admin(.*)$ https://example.com/admin$1 [L,R=301]
#</LocationMatch>
CustomLog /var/log/apache2/askbot/access_log common
ErrorLog /var/log/apache2/askbot/error_log
LogLevel debug
</VirtualHost>
Thanks again for the support. :)
the LOGIN_URL in default settings.py is computed based on ASKBOT_URL. You can change the LOGIN_URL manually.
Alternatively you can add Alias directive to your apache config for the wiki so that wiki is not served by django.
Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.
create your Q&A siteAsked: 2010-09-23 01:11:57 -0500
Seen: 472 times
Last updated: Sep 24 '10
How to install askbot on Ubuntu with LAMP?
Configuring Askbot with Apache
GET /m/default/media/style/style.css?v=2 HTTP/1.1" 404
Unable to start Apache Server-Error in RewriteEngine
images and stylesheets not found
How do I change the help page text?
Error when saving user information
Copyright Askbot, 2010-2011. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.