Localhost:2368 404, localhost:2368/blog 301


#1

I think I have the same issue described here: https://github.com/TryGhost/Ghost/issues/7279

  • What’s your URL? This is the easiest way for others to debug your issue
    Right now I’m testing against the nodejs server directly (localhost:2368, however the url configured is:mydomain.com/blog/

  • What version of Ghost are you using?
    Ghost-CLI version: 1.8.1
    Ghost Version (at /var/www/…/ghost): 1.25.4

  • What configuration?
    {
    “url”: “https://mydomain.com/blog/”,
    “server”: {
    “port”: 2368,
    “host”: “127.0.0.1”
    },
    “database”: {
    “client”: “mysql”,
    “connection”: {
    “host”: “10.89.8.45”,
    “user”: “ghost”,
    “password”: “XXXX”,
    “database”: “ghost”
    }
    },
    “mail”: {
    “transport”: “Direct”
    },
    “logging”: {
    “transports”: [
    “file”,
    “stdout”
    ]
    },
    “process”: “systemd”,
    “paths”: {
    “contentPath”: “/var/www/…/ghost/content”
    }
    }

  • What browser?
    curl

  • What errors or information do you see in the console?

$ curl -I localhost:2368

HTTP/1.1 404 Not Found
X-Powered-By: Express
Content-Security-Policy: default-src ‘self’
X-Content-Type-Options: nosniff
Content-Type: text/html; charset=utf-8
Content-Length: 140
Date: Mon, 13 Aug 2018 16:23:41 GMT
Connection: keep-alive

curl -I localhost:2368/blog/

HTTP/1.1 301 Moved Permanently
X-Powered-By: Express
Cache-Control: public, max-age=31536000
Location: localhost:2368/blog/
Vary: Accept, Accept-Encoding
Content-Type: text/plain; charset=utf-8
Content-Length: 62
Date: Mon, 13 Aug 2018 16:23:44 GMT
Connection: keep-alive

  • What steps could someone else take to reproduce the issue you’re having?
    Installing from the beginning and using the provided config.

Also if I change the URL from the config file to http://127.0.0.1:2368 then I get an HTTP code 200 from the curl (so it works), but later when I access the site through the apache redirection, all links are pointing to 127.0.0.1:2368

Any idea what I’m doing wrong?

Thanks in advance.


#2

I’ve fixed it, but I’m not sure if I’m doing something wrong. The way I fixed it has been changing the https by http in the url setting.

Should I have configured a SSL certificate for the nodejs server?


#3

The https is definitely the reason you were seeing a 301 - if Ghost receives a http request when a https url is configured then it will redirect to the https version.

If you’re only testing locally then sticking with http is fine. If you’re setting up a production install ghost-cli will handle the https and certificate set up for you, alternatively if you’re configuring things manually ensure that you match all the required headers in your nginx/apache config.


#4

Hello @Kevin, and thanks for the reply.

Do I need to set anything in the ghost side regarding the SSL? I think I have everything set up in my apache conf (when URL in ghost is without https, everything works perfectly).

The only documentation that I found (https://docs.ghost.org/v0.11/docs/how-to-setup-ssl-for-self-hosted-ghost) was regarding how to create the SSL certificate and configuration for Nginx, but I already have that set up with Apache.

With the ghost install the ssl certification configuration is skipped if you skip the Nginx configuration, so I’m not sure if in that step, something is done for ghost too. Is there any way to configured manually?

Best,
Bart.


#5

All SSL termination is done at the web server/proxy level so if you’ve set up Apache to do that then you’re pretty much there :smile: The only thing Ghost needs is for your Apache proxy to pass the required headers so it can handle the request properly.


#6

Thanks Kevin,

I finally got it done. In case somebody run into the same problem, my Apache configuration is:

    <Location /blog/>
            ProxyPreserveHost On
            ProxyPass http://localhost:2368/blog/
            ProxyPassReverse http://localhost:2368/blog/
            RequestHeader set X-Forwarded-Proto "https"
    </Location>

I need it to be access as a subfolder of the primary domain.

Thanks for the help @Kevin!

Best,
Bart.