0

I have deployed Vue.js and Django E-commerce on VPS, where I set up Nginx and Gunicorn. All pages are working fine, all pages from Vue.js and the Admin area of Django. But when it comes to use forms and basically do anything related with /api/v1/ it gets ERROR 502. What could be wrong? I have no idea how to solve that and I've been having this error for over a few days. Hope you could help. Thank you!

Here is my Nginx:

upstream perulab_app_server {
    server unix:/webapps/perulab/venv/run/gunicorn.sock fail_timeout=0;
}

server {
    listen 8000;
    listen [::]:8000;
    server_name 172.16.7.52;

    client_max_body_size 40M;


    location / {
        root /webapps/perulab/web-frontend/dist;
        try_files $uri /index.html;
    }


    location /static/ {
        root /webapps/perulab/web-backend;
    }

    location /media/ {
        root /webapps/perulab/web-backend;
    }

    location /api/ {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://perulab_app_server/api/;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_redirect off;
    }

    location /admin/ {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://perulab_app_server/admin/;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_redirect off;
    }



}
Michael Hampton
  • 237,123
  • 42
  • 477
  • 940
  • Which software sent the 502 error? – Michael Hampton Sep 27 '21 at 20:19
  • In Chrome console, when Axios is trying to access DRF api to send contact email for example or any other form. But it does show products, which is strange. @MichaelHampton – Ivan Stepanchuk Sep 27 '21 at 20:20
  • I didn't wat to use subdomains, I wanted to make them use the same port. When running "gunicorn --bind 172.16.7.52:8000 core.wsgi" it says connection in use. @MichaelHampton – Ivan Stepanchuk Sep 27 '21 at 20:25
  • Do you mean that your application sent the 502 error? That seems quite odd. – Michael Hampton Sep 27 '21 at 20:25
  • Yes, the page stays the same but the console returns POST http://172.16.7.52:8000/api/v1/contacto/ 502 (Bad Gateway). – Ivan Stepanchuk Sep 27 '21 at 20:27
  • Look at the response body from that request. – Michael Hampton Sep 27 '21 at 20:30
  • AssertionError at /api/v1/contacto/ Expected a `Response`, `HttpResponse` or `HttpStreamingResponse` to be returned from the view, but received a ``, this is strange, because when on local machine it was sending just fine. – Ivan Stepanchuk Sep 27 '21 at 20:32
  • @MichaelHampton It looks like some APIs work, and all of them that work they have one thing in common - they don't send emails. All the rest of APIs like contact or Password Change for example that sends an email, creates this Error 502. Still don't know how to solve that. – Ivan Stepanchuk Sep 27 '21 at 21:36

0 Answers0