Nginx

This section described how to use nginx (https://nginx.org/en/) as a web server. The Platform's server components can be made highly performant by using the lightweight Nginx as a reverse-proxy along with a WSGI server. Using nginx enabled the server to scale to a large number of users with ease.
To use Nginx, it needs to be installed in the system the daemon should be running with the appropriate site configurations setup.
Installation
The official installation instructions can be found at https://nginx.org/en/docs/install.html
The recommended method of installation is to use the package manager provided by the Operating System (apt-get, yum, etc.).
RedHat:
yum install nginx
Ubuntu:
apt install nginx
Configurations
Once installed, the nginx configuration needs to be created to proxy the web server components as described in https://nginx.org/en/docs/beginners_guide.html#proxy
Here is an example nginx configuration that sets up the Web Application Server and also routes the
/jupyter endpoint to the Jupyter component:
server {
listen 80;
server_name localhost 0.0.0.0;
client_max_body_size 100m;
gzip on;
gzip_vary on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/javascript application/xml application/json ;
gzip_disable "MSIE [1-6]\.";
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_pass http://localhost:5002;
proxy_read_timeout 3600;
}
location /jupyter {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_pass http://localhost:5003;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
}
Note
If the nginx is not listening on port 80 - but listens on another port, the
proxy_set_header for Host may have to be modified to proxy_set_header Host $http_host to
ensure the correct host information is passed.
Note: Permission issues
In case of permission issues, ensure user permissions and SELinux is set up correctly.
Note: Large file uploads
If large files are expected to be uploaded, there are two settings that need to be modified
1. add proxy_request_buffering off
2. add client_max_body_size 0;
to server directive which expects large file size payload.
This will disable nginx from buffering the large payload files and optimize disk space consumption.