First time here? Check out the FAQ!
2

How to serve Askbot under a subpath in NGINX?

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!

iainbryson's avatar
21
iainbryson
asked 2016-10-19 10:04:52 -0600
Evgeny's avatar
13.2k
Evgeny
updated 2016-12-22 09:22:07 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

0

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

gopalraha's avatar
332
gopalraha
answered 2016-10-26 04:50:58 -0600
edit flag offensive 0 remove flag delete link

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's avatar iainbryson (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's avatar gopalraha (2016-10-29 13:42:05 -0600) edit
add a comment see more comments
0

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.

Evgeny's avatar
13.2k
Evgeny
answered 2016-12-22 09:17:59 -0600, updated 2016-12-22 09:32:09 -0600
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments