Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment in Apache with mod_wsgi: deploy at non-root path #408

Closed
1 task
RKrahl opened this issue Mar 25, 2023 · 1 comment · Fixed by #409
Closed
1 task

Deployment in Apache with mod_wsgi: deploy at non-root path #408

RKrahl opened this issue Mar 25, 2023 · 1 comment · Fixed by #409
Assignees

Comments

@RKrahl
Copy link
Contributor

RKrahl commented Mar 25, 2023

Description:
datagateway-api works fine when deployed in Apache with mod_wsgi, if it is deployed at the document root.

E.g., if you have something like the following:

httpd.conf:

<VirtualHost _default_:443>

        ServerName data.example.org:443

        WSGIDaemonProcess datapub \
                display-name=%{GROUP} user=wwwrun group=www threads=3
        WSGIScriptAlias / /usr/lib/python3.6/site-packages/datagateway_api/wsgi.py \
                process-group=datapub application-group=%{GLOBAL}

</VirtualHost>

config.yaml:

search_api:
  extension: "/search-api"

The search API works and is reachable at https://data.example.org/search-api.

However, this is very inconvenient, as it shadows the whole URL tree, because any request will be absorbed by the WSGI application. Nothing else besides /search-api is reachable at https://data.example.org/ anymore, unless it is explicitely aliased.

For HZB this is also a problem, because I normally want to have a redirection from https://data.helmholtz-berlin.de/ to the ICAT web UI at https://topcat.hemlholtz-berlin.de/. This redirection is now lost after I deployed the search API as described above at https://data.helmholtz-berlin.de/search-api. I can't resurrect that redirection with an explicit alias, because I can't redirect / at the same time as having a WSGI script alias at /.

Obviously, what I would like to do is that only requests to the search API will be handled by the WSGI script. E.g., I would like to configure something like

<VirtualHost _default_:443>

        ServerName data.example.org:443

        WSGIDaemonProcess datapub \
                display-name=%{GROUP} user=wwwrun group=www threads=3
        WSGIScriptAlias /search-api /usr/lib/python3.6/site-packages/datagateway_api/wsgi.py \
                process-group=datapub application-group=%{GLOBAL}

</VirtualHost>

in the httpd.conf.

But that doesn't seem to work.

If I try this with the same config.yaml as above, I get a 404 Not found at https://data.example.org/search-api. The search API is apparently listening at https://data.example.org/search-api/search-api, but it does not work properly, because Swagger tries to load the API definition from https://data.example.org/search-api/openapi.json, which fails. It is available at https://data.example.org/search-api/search-api/openapi.json instead.

If I try to deploy the WSGI at /search-api as above and set the following in the config.yaml:

search_api:
  extension: ""

Then the search API is again apparently listening at https://data.example.org/search-api, but I get just a blank page. The reason becomes obvious obvious if I look into the HTML source:

<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>Search API OpenAPI Spec</title>
  <link rel="stylesheet" type="text/css" href="/index.css">
  <link rel="stylesheet" type="text/css" href="/swagger-ui.css">
  <link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32" />
  <link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16" />
</head>

<body>
  <div id="swagger-ui"></div>

  <script src="/swagger-ui-bundle.js"> </script>
  <script src="/swagger-ui-standalone-preset.js"> </script>
  <!-- ... -->
</body>

</html>

It tries to load its components (CSS and JS) from /... instead of /search-api/..., which obviously must fail.
Essentially the same happens if I put extension: "/" in the config.yaml.

Acceptance criteria:

  • get deploying of the search API using WSGIScriptAlias /search-api ... to work.
@louise-davies louise-davies self-assigned this Mar 29, 2023
@louise-davies
Copy link
Member

Note, deploying under an alias via WSGIScriptAlias does work - in fact this is what we do at ISIS with datagateway api configured as "/" and search api configured as "/search-api" - if you ping the API using the ping command /ping it should respond under the WSGIScriptAlias and all other requests work as normal. However, yes the swagger UI does not load in the case of the "/" alias, so what I'm working on should fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants