Web Application Setup - Nginx Set Up
NGINX SET UP
-
Create your apps nginx configuration
... touch /var/www/appname/config/nginx-appname.cfg -
The content of your
nginx-appname.cfgfiles should look like this:upstream appname { server unix:/var/run/uwsgi/appname.socket; } server { listen 80; server_name SERVER_IP SERVER_DOMAIN; location = /favicon.ico { access_log off; log_not_found off; } location /static/ { root /var/www/appname/; } location / { uwsgi_pass appname; include /etc/nginx/uwsgi_params; } } -
Link your nginx config file to nginx’ site config directory:
... cd /etc/nginx/sites-enabled ... ln -s /var/www/appname/config/appname-nginx.cfg appname -
You can check your nginx config by running the following:
... sudo nginx -t -
Make sure we have the firewall open for nginx:
Check the available apps:
... sudo ufw app list Available applications: Nginx Full Nginx HTTP Nginx HTTPS OpenSSH ...Add one of the nginx options:
... sudo ufw allow 'Nginx Full' # enable the firewall ... sudo ufw enable -
Restart nginx.
... sudo systemctl restart nginxAfter this you should be able to access your static files via a webbrowser.