Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gem/oq-engine
Browse files Browse the repository at this point in the history
  • Loading branch information
micheles committed Nov 13, 2023
2 parents 15fd259 + b2bf739 commit b86affd
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions doc/installing/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ $ sudo oq webui collectstatic

*nginx* must be configured to act as a reverse proxy for *gunicorn* and to provide static content. A [sample configuration file](examples/nginx.md) is provided.

When the reverse proxy is configured, add the following to `openquake/server/local_settings.py`:
```python
USE_REVERSE_PROXY = True
```

***

## Getting help
Expand Down
6 changes: 6 additions & 0 deletions openquake/server/local_settings.py.aelo
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ APPLICATION_MODE = 'aelo'

# turn on USE_X_FORWARDED_HOST to expose the webui via a proxy server
# USE_X_FORWARDED_HOST = True
# USE_X_FORWARDED_PORT = True

# enable WEBUI_PATHPREFIX to place webui pages below a specific path
# WEBUI_PATHPREFIX='/path/prefix'
Expand All @@ -28,6 +29,11 @@ SERVER_NAME = <localhost>
SERVER_PORT = <8800>
USE_HTTPS = <False>

# Set to True if using NGINX or some other reverse proxy
# Externally visible url and port number is different from Django visible
# values
USE_REVERSE_PROXY = <False>

WEBUI_ACCESS_LOG_DIR = '/var/log/oq-engine'

# Local time zone for this installation. Choices can be found here:
Expand Down
9 changes: 9 additions & 0 deletions openquake/server/management/commands/createnormaluser.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ def handle(self, *args, **kwargs):
request = HttpRequest()
request.META['SERVER_NAME'] = settings.SERVER_NAME
request.META['SERVER_PORT'] = settings.SERVER_PORT
if settings.USE_REVERSE_PROXY:
if settings.USE_HTTPS:
request.META['SERVER_PORT'] = '443'
else:
request.META['SERVER_PORT'] = '80'
else:
request.META['SERVER_PORT'] = settings.SERVER_PORT
if settings.APPLICATION_MODE.upper() == 'AELO':
password_reset_subject = (
'registration/normal_user_creation_email_subject_aelo.txt')
Expand All @@ -56,6 +63,8 @@ def handle(self, *args, **kwargs):
email_template_name = (
'registration/normal_user_creation_email.txt')
form.save(
domain_override=(settings.SERVER_NAME
if settings.USE_REVERSE_PROXY else None),
request=request,
use_https=settings.USE_HTTPS,
from_email=settings.EMAIL_HOST_USER,
Expand Down
6 changes: 5 additions & 1 deletion openquake/server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@
# case insensitive
APPLICATION_MODE = 'public'

# Set to True if using NGINX or some other reverse proxy
# Externally visible url and port number is different from Django visible
# values
USE_REVERSE_PROXY = False

# Expose the WebUI interface, otherwise only the REST API will be available
WEBUI = True

Expand Down Expand Up @@ -251,7 +256,6 @@
f' must all be defined')

if LOCKDOWN:

# do not log to file unless running through the webui
if getpass.getuser() == 'openquake': # the user that runs the webui
try:
Expand Down

0 comments on commit b86affd

Please sign in to comment.