简体   繁体   中英

NGINX ERROR :connect() failed (111: Connection refused) while connecting to upstream

I get that error in title when I cat out the error.log

this is how I set my website config inside /etc/nginx/site-availables/ArticleWebsite :


server_tokens               off;
access_log                  /var/log/nginx/ArticleWebsite.access.log;
error_log                   /var/log/nginx/ArticleWebsite.error.log;

# This configuration will be changed to redirect to HTTPS later
server {
  server_name               backend.globeofarticles.com;
  listen                    443 ssl;
  ssl_certificate           /etc/letsencrypt/live/backend.globeofarticles.com/fullchain.pem;
  ssl_certificate_key       /etc/letsencrypt/live/backend.globeofarticles.com/privkey.pem;
  location / {
    proxy_pass              http://127.0.0.1:8000;
    proxy_set_header        Host $host;
  }
}


to explain my situation better, backend.globeofarticles.com is the subdomain, that where the requests are sent from globeofarticles.com or www.globeofarticles.com .

Also, Django has 127.0.0.1:8000 host as default.

when I access the website (backend subdomain) I get this error:

在此处输入图像描述

when checking network tab, I get too many redirects actually:

在此处输入图像描述

with status code 301

try this for ur nginx config. then u can reinstall certbot for this domain. using certbot --nginx

   server {
   server_name backend.globeofarticles.com;
   root /var/www/backend.globeofarticles.com/html/;
   index index.php index.html index.htm index.nginx-debian.html;
 
   location / {
     try_files $uri $uri/ /index.php;
   }
 
   location ~ \.php$ {
     fastcgi_pass unix:/run/php-fpm/www.sock;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     include fastcgi_params;

   }

  # A long browser cache lifetime can speed up repeat visits to your page
   location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {
        access_log        off;
        log_not_found     off;
        expires           360d;
   }

   # disable access to hidden files
   location ~ /\.ht {
       access_log off;
       log_not_found off;
       deny all;
   }
    

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM