Put an nginx reverse-proxy in front of the voila server to give us more flexibility in how we present the endpoint.

This commit is contained in:
Phil Elson 2020-11-02 17:25:58 +01:00
parent cf2ca07768
commit d44ae5501f
6 changed files with 108 additions and 1 deletions

View file

@ -25,3 +25,15 @@ trigger_build_on_openshift:
- if: '$OPENSHIFT_BUILD_WEBHOOK_SECRET'
script:
- curl -X POST -k https://openshift.cern.ch:443/apis/build.openshift.io/v1/namespaces/cara/buildconfigs/cara-app/webhooks/${OPENSHIFT_BUILD_WEBHOOK_SECRET}/generic
deploy_to_test:
stage: deploy
rules:
- if: '$CI_MERGE_REQUEST_EVENT_TYPE == "detached"'
when: never
- if: '$OPENSHIFT_TEST_BUILD_WEBHOOK_SECRET'
when: manual
allow_failure: true
script:
- curl -X POST -k https://openshift-dev.cern.ch:443/apis/build.openshift.io/v1/namespaces/test-cara/buildconfigs/test-cara/webhooks/${OPENSHIFT_TEST_BUILD_WEBHOOK_SECRET}/generic

View file

@ -7,6 +7,19 @@
## Development guide
### Building the docker image for local execution
**Simulate the docker build that takes place on openshift with:**
```
s2i build file://$(pwd) --copy --context-dir=app-config/nginx/ centos/nginx-112-centos7 cara-nginx-app
s2i build file://$(pwd) --copy --context-dir=./ centos/python-36-centos7 cara-voila-app
cd app-config
docker-compose up
```
Then visit localhost:8080.
### Setting up the application
The https://cern.ch/cara application is running on CERN's OpenShift platform. In order to set it up for the first time, we followed the documentation at https://cern.service-now.com/service-portal?id=kb_article&n=KB0004498. In particular we:

View file

@ -0,0 +1,13 @@
version: "3.8"
services:
cara-app:
image: cara-voila-app
# ports:
# - "8080:8081"
links:
- cara-router
cara-router:
image: cara-nginx-app
ports:
- "8080:8080"

View file

@ -0,0 +1,3 @@
<p>
Welcome! Please see <a href="/expert-app">the expert application</a>.
</p>

View file

@ -0,0 +1,65 @@
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name _;
root /opt/app-root/src;
# Load configuration files for the default server block.
include /opt/app-root/etc/nginx.default.d/*.conf;
large_client_header_buffers 4 16k;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location /voila-server/ {
proxy_pass http://cara-app:8080/voila-server/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
rewrite ^/expert-app$ /voila-server/voila/render/cara.ipynb last;
# Before implementing the nginx router we could access /voila/render/cara.ipynb.
# Redirect this (and all other) URLs to the new scheme.
rewrite ^/voila/(.*)$ /voila-server/voila/$1 redirect;
}
}

3
app.sh
View file

@ -1 +1,2 @@
voila app/ --port=8080
voila app/ --port=8080 --no-browser --base_url=/voila-server/ --Voila.tornado_settings="{'allow_origin': '*'}"