revised: 25-Dec-2021
Part D1: Establish 'myproject.service' is active
Part D2. Configuring Nginx to serve Flask
Assumption: Nginx Webserver is installed and Webmin configured for adjustments on Nginx. If the Nginx module is not installed in Webmin, see the following: iRedMail-Extras-PartA
Step01: Configure Nginx to Proxy to uWSGI
Enter Webmin [https://MySeverIP:10000] and go to [Servers]-> [Nginx Webserver]->[YourDomain eg.example.com]. Change the server block script similar to this, but changing the domain (example.com) to your own domain:
server { listen 80; server_name example.com www.example.com; return 301 https://example.com$request_uri; return 301 https://www.example.com$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; server_name example.com www.example.com; location / { include uwsgi_params; uwsgi_pass unix:/home/sammy/myapp/myproject.sock; } ssl_certificate /etc/ssl/certs/iRedMail.crt; ssl_certificate_key /etc/ssl/private/iRedMail.key; ssl_prefer_server_ciphers on; ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log info; }
Restart Nginx, open the browser with your domain (eg.https://example.com)
The same msg 'Hello There!' should appear in red. To serve the 3-page website (assuming you have synchonized the files to the server) do the following:
Note: Remember restart systemctl service whenever changes to the website pages are made.
Reference: how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04
Notes for the mail-enhanced site:
Two remaining steps are required as follows;
1. Modify the settings in 'project.py' by changing 'example.com' with one's own domain and modifying the 'SECRET_KEY'
2. Create the mailbox: info@yourdomain.com via the 'iredadmin' page.
Flask | Flask-PartB |
Flask-PartC | Flask-PartD |