6

I followed the official documentation guide:

  1. https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment/hosting-guides/digitalocean.html
  2. https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment/optional-software/nginx-proxy.html#configuration

Could someone tell me what's wrong with my configuration ? I keep getting an error message in /var/log/nginx/error.log:

2022/04/05 04:02:26 [error] 2528816#2528816: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 176.x.x.x, server: api.example.com, request: "GET / HTTP/1.1", upstream: "http://167.x.x.x:1337/", host: "api.example.com"

Here are the configuration files:

# strapi/config/server.js

module.exports = ({ env }) => ({
  host: env('HOST', '0.0.0.0'),
  port: env.int('PORT', 1337)
});
# /etc/nginx/sites-available/strapi.conf
server {

# Listen HTTP
    listen 80;
    server_name api.example.com;

# Proxy Config
    location / {
        proxy_pass http://api.example.com:1337;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass_request_headers on;
    }
}
# /etc/nginx/conf.d/upstream.conf
upstream strapi {
    server 127.0.0.1:1337;
}
aspirinemaga
  • 3,753
  • 10
  • 52
  • 95

0 Answers0