Ask Your Question
1

How to serve Askbot under a subpath in NGINX?

asked 2016-10-19 10:04:52 -0600

iainbryson gravatar image

updated 2016-12-22 09:22:07 -0600

Evgeny gravatar image

Hi there,

I'm trying to figure out how to host askbot under a subpath within our system.

So far I've tried investigating setting these:

ASKBOT_APP_URL = "hach tee tee pee colon slash slash url.dk/askbot/"

ASKBOT_URL = 'askbot/'

Neither worked.

I tried searching for a solution, but all I find is question 8211 (can't post link due to karma) from 2012.

And it seems they reference Apache in their (self-described) hack solutions.

So: (1) is there a "real" way to serve askbot from a subsite? (nginx proxying requests into the askbot, but the askbot generating URL for the subpath) (2) is there a hack for nginx?

Thanks!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-12-22 09:17:59 -0600

Evgeny gravatar image

updated 2016-12-22 09:32:09 -0600

In the nginx config the key is to connect the base url to the upstream server (other parameters - the same as usual):

location /subdir/ {
    uwsgi_pass unix:///var/uwsgi/mysite.sock; # using a Unix socket here, as one of the options
    include uwsgi_params;
}

In the settings.py file:

ASKBOT_URL = 'subdir/' # without the leading slash
# If uploaded files urls and media also need to be custom
# adjust parameters `MEDIA_URL` and `STATIC_URL` to be the same as locations
# in the nginx config.

The above is sufficient for me with the uwsgi upstream Python app server, with Django 1.8.

If you are using mod_wsgi - FORCE_SCRIPT_NAME might need to be set in the settings.py - I haven't tested, but it should be similar to ASKBOT_URL value, give or take the slashes. This might also be needed for other Python app servers, including uwsgi - I haven't tested older versions.

edit flag offensive delete link more
0

answered 2016-10-26 04:50:58 -0600

Yes you can do it by editing a nginx virtual configuration file afterwards edit the 'settings.py' file.

edit flag offensive delete link more

Comments

If I understand you, that's what I think I'm doing, without success. When you say, 'edit the settings.py', do you mean something more than that ASKBOT_URL or ASKBOT_APP_URL? When you say, 'edit the nginx virtual config', do you mean something like:

upstream askbot {
   least_conn;
   server askbot:8000 weight=10 max_fails=3 fail_timeout=30s;
}

server {
   listen 443 ssl;
   server_name root.foo.bar;
 
   location /askbot {
      proxy_pass                  http://askbot;
      proxy_set_header            Host $host;
      proxy_set_header            X-Real-IP $remote_addr;
      proxy_http_version          1.1;
      proxy_set_header            X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header            X-Forwarded-Proto https;
      proxy_redirect off;
   }

   location /m {
      proxy_pass                  http://askbot;
      proxy_set_header            Host $host;
      proxy_set_header            X-Real-IP $remote_addr;
      proxy_http_version          1.1;
      proxy_set_header            X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header            X-Forwarded-Proto https;
      proxy_redirect off;
   }


...

?

iainbryson gravatar imageiainbryson ( 2016-10-27 17:39:21 -0600 )edit

This is an incorrect settings for more info please rollover through official askbot documentation http://askbot.org/doc/index.html

gopalraha gravatar imagegopalraha ( 2016-10-29 13:42:05 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-10-19 10:04:52 -0600

Seen: 430 times

Last updated: Dec 22 '16