` Flask + Nginx + gunicorn gives 403 » Motion design agency graphics studios

Flask + Nginx + gunicorn gives 403

I am trying to deploy a flask application on a Cent OS 7 server that has Plesk, on a subdomain. To deploy it I am using gunicorn and Nginx.

When I am trying to go to the subdomain I would expect to see the web application running but I am getting a 403 error and in Plesk subdomain logs I am getting:

4679#0: *29 directory index of "/var/www/vhosts/domain.com/subdomain.domain.com/" is forbidden 

/etc/nginx/conf.d/app.conf:

server { listen 80; server_name subdomain.domain.com; access_log /var/log/app_access.log; error_log /var/log/app_error.log; location / { proxy_pass http://localhost:8000; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /static { alias /var/www/vhosts/domain.com/subdomain.domain.com/app/static; expires 30d; } } 

To start gunicorn I am using:

gunicorn -b localhost:8000 -w 4 app:app 

I've already tried:

  • setting user root; in nginx config file
  • setting 775 for permissions
  • made sure SELinux is not active

I've looked on internet and I've seen that this error might appear because there is no index file, so I've also tried to add dummy file manually in the application directory and the subdomain displays the dummy index file, but when I try to access a page that is from my application I am getting 404. This makes me think that nginx doesn't redirect requests to gunicorn because my application has an index.html file in the template folder.

I am not a DevOps person so in case I've done something stupid in terms of deployment, please tell me.

submitted by
---
[fixed][/fixed]
jodo