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!

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
iainbryson's avatar
21
iainbryson
asked 8 years ago
Evgeny's avatar
13.2k
Evgeny
updated 8 years ago

Comments

see more comments

2 Answers

0

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

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
gopalraha's avatar
332
gopalraha
answered 8 years ago
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 (8 years ago)

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

gopalraha's avatar gopalraha (8 years ago)
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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
answered 8 years ago, updated 8 years ago
link

Comments

see more comments