Error 521 but working through IP

I just followed the installation instructions for Ubuntu 18.04, all went fine but whenever I try to access my blog thought the URL I get Error 521, so server down. If I use my IP then I get the “Welcome to nginx” default page, I ran ghost doctor but I get no errors, talked to my hosting provider and told me that the DNS config was fine. So I’m not sure where to take it from here, any ideas?

my ghost config:

 {
      "url": "https://myurl.com",
  "server": {
	"port": 2368,
    "host": "localhost"
  },
  "privacy": {
    "useTinfoil": true
	},
  "database": {
    "client": "mysql",
    "connection": {
      "host": "localhost",
      "user": "user",
      "password": "pass",
      "database": "ghost_prod"
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/www/ghost/content"
  },
  "bootstrap-socket": {
    "port": 8000,
    "host": "localhost"
  }
}

and nginx

server {
    listen 80;
    listen [::]:80;

    server_name myurl.com;
    root /var/www/ghost/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://localhost:2368;
        
    }

    location ~ /.well-known {
        allow all;
    }

    client_max_body_size 50m;
}

hosts file

127.0.0.1	localhost
127.0.1.1	my.myurl.com

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

nginx status

● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-06-09 11:46:51 PDT; 13s ago
     Docs: man:nginx(8)
  Process: 1128 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=
  Process: 1130 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 1129 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 1131 (nginx)
    Tasks: 2 (limit: 525)
   CGroup: /system.slice/nginx.service
           ├─1131 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           └─1133 nginx: worker process

ghost doctor

$ ghost doctor
✔ Checking system Node.js version
✔ Checking logged in user
✔ Ensuring user is not logged in as ghost user
✔ Checking if logged in user is directory owner
✔ Checking current folder permissions
✔ Checking operating system compatibility
✔ Checking for a MySQL installation
+ sudo systemctl is-active ghost_myurl_com
Instance is currently running
ℹ Validating config [skipped]
✔ Checking folder permissions
✔ Checking file permissions
✔ Checking content folder ownership
✔ Checking memory availability

Hey @mistermarx!

Which URL do you visit to the the 521 response?

Your ghost blog has it’s url configured to use the https protocol, but your nginx is listening on port 80 (default for http proto) - If nginx isn’t configured to listen on port 443 and use ssl, then I can see this being the cause of the issue.

Yeah, it was a port/ssl misconfig and cloudflare

Unfortunately I tried so many things that I am not sure what fixed it…

But now it’s fixed. :slight_smile:

1 Like