Phillip YS
Phillip YS

Reputation: 904

Ghost gives me 404 error on AWS EC2

As you can see I get no errors during ghost start

enter image description here

but when I actually go to the page http://13.125.83.25 (Elastic IP of the EC2 instance), there's nothing. page doesn't load anything. no idea why this happens, I'm new to ghost module. what am I missing?

here's config.production.json below.

{
  "url": "http://13.125.83.25",
  "server": {
    "port": 2368,
    "host": "127.0.0.1"
  },
  "database": {
    "client": "mysql",
    "connection": {
      "host": "localhost",
      "user": "",
      "password": "", // just hided
      "database": ""
    }
  },
  "mail": {
    "transport": "Direct"
  },
  "logging": {
    "transports": [
      "file",
      "stdout"
    ]
  },
  "process": "systemd",
  "paths": {
    "contentPath": "/var/www/ghost/content"
  }
}

and Here's /etc/nginx/sites-available/default

server {
        listen 80;

        root /var/www/html;

        server_name _;

        location / {
                proxy_pass http://127.0.0.1:2368;
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }

Upvotes: 0

Views: 683

Answers (1)

naveen yagati
naveen yagati

Reputation: 11

You should fill your IP/DomainName near the server_name and make sure you are having the right port near the proxy_pass beacause sometimes when you run ghost restart it changes the port number.So in order to check the port number run the folowing command ghost ls and check the port number of your running ghost process.Use the following config for your Nginx server,hope it helps.

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

    server_name 13.125.83.25;
    root /var/www/ghost/system/nginx-root;

    location /blog {
        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://127.0.0.1:2368;

    }

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

    client_max_body_size 50m;
}

Upvotes: 1

Related Questions