NGINX Web Server

NGINX is a strong option as the reverse proxy web server for Pyramid. It is especially useful for Linux deployments. It can be used in Windows as well. However, the IIS option for Windows is often more convenient.

Installing and Configuring NGINX

These instructions are for Ubuntu/Debian Linux.

Install NGINX

sudo apt-get update

sudo apt-get install nginx

Configure the NGINX Default file

now go to /etc/nginx/sites-available. Open the default file and edit it.

Add/Edit the following text in the default file

server { listen 80 default_server; listen [::]:80 default_server; # only required for SSL processing return 301 https://$host$request_uri; }

Next, add another set of entries to this file for the SSL certificate processing (if required) inside the second "server" node of the file. Be sure to use your names for the CRT and KEY files for your SSL certification.

listen 443 ssl default_server; listen [::]:443 ssl default_server; ssl_certificate /etc/ssl/certs/ssl-bundle.crt; ssl_certificate_key /etc/ssl/private/comodo.key;

Add another entry:

server_name www.mysite.com;   location / { proxy_pass http://127.0.0.1:8181; }   location /events { proxy_pass http://127.0.0.1:8181/events; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }

Other Settings

Setting NGINX file upload limit:

sudo vim /etc/nginx/nginx.conf

add the following lines under the http section and save the file:

client_max_body_size 500M;

Save and restart the NGINX service:

sudo systemctl reload nginx