oq-engine icon indicating copy to clipboard operation
oq-engine copied to clipboard

Serve openquake on a different context path

Open adnanesaghir opened this issue 2 years ago • 4 comments

Hi, is there a way to serve openquake on a different context path? For example for a custom path mypath we'd like to have:

  • http://localhost:8800/mypath/accounts/login/ instead of http://localhost:8800/accounts/login/
  • http://localhost:8800/mypath/engine instead of http://localhost:8800/engine
  • http://localhost:8800/mypath/v1/engine_version instead of http://localhost:8800/v1/engine_version

adnanesaghir avatar May 19 '22 14:05 adnanesaghir

You have to change the django routes, see https://github.com/gem/oq-engine/blob/master/openquake/server/urls.py

micheles avatar May 23 '22 13:05 micheles

Thanks for your reply, but it would be great if we have the option as a parameter so we won't compile the code each time

I'd suggest adding a CONTEXT parameter and use it like below

Example for docker: docker run -d --name openquake -p 80:8800 -e CONTEXT=/openquake openquake/engine:latest

adnanesaghir avatar May 23 '22 13:05 adnanesaghir

We accept pull requests.

micheles avatar May 25 '22 04:05 micheles

Sorry i'm not a Python developer :) I tried with FORCE_SCRIPT_NAME = "/openquake" in settings.py but it doesn't seem to work I would like to implement the feature in one place without touching all the url paths in urls.py Something like what I'm used to do in Node.js , please see this nodejs sample app

  • app routes (urls) definition: https://github.com/adnanesaghir/expressjs-app/blob/master/routes.js
  • setting secondary custom app path from an environment variable in one line without touching default routes: https://github.com/adnanesaghir/expressjs-app/blob/49f73bfcaaf663d065c217bb5c659f9d736ef50b/app.js#L8

adnanesaghir avatar Aug 24 '22 12:08 adnanesaghir

This is implemented in current master as documented here: https://github.com/gem/oq-engine/blob/master/docker/README.md (see the section on WEBUI_PATHPREFIX).

micheles avatar Nov 21 '22 13:11 micheles