Score:0

nginx displaying IP instead of domain with ghost

ng flag

The current situation is as follows: I have a domain at a specific provider (manitu.de) I have a free tier VPS with Oracle I want to set up a ghost blog on the oracle VPS that should be reachable via the domain I have at manitu.de

So this is what happened until now: I’ve set the IPv4 Forward-DNS A record for mydomain.de to forward to the IP of the Oracle server (let’s assume 1.2.3.4). During the ghost installation, it asks me for the name of my blog. So if I go and provide 1.2.3.4 as IP, I can reach the blog by using 1.2.3.4/ghost as well as mydomain.de/ghost - which is nice.

My problem: if I enter mydomain.de (or mydomain.de/ghost fwiw) in the address bar, it redirects to 1.2.3.4 which I want to avoid. That’s what I haven’t been able to solve properly yet because either it doesn’t redirect anywhere at all or I get stuck in a loop of redirections.

This is what my configuration looks like which is created by ghost during the installation process which I have added the second server block to:

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

    server_name mydomain.de;
    root /var/www/mydomain/system/nginx-root; # Used for acme.sh SSL verification>

    return 301 $scheme://mydomain.de$request_uri;

    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://127.0.0.1:2368; # 2368 being the port ghost is using

    }

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

server {
    listen 80;
    server_name 1.2.3.4;
    return 301 $scheme://mydomain.de$request_uri;
}

Thanks in advance!

Score:1
us flag

Since you have configured the root URL of your application to be an IP address, then the application makes sure all requests are made to the root URL of the application.

So, the proper solution is to set the root URL of the application properly. After that, accessing the application with an IP address will redirect it to the root URL.

awake avatar
ng flag
Hey there, thanks for answering. So basically I need to switch out the IP in my second server block for the right domain?
us flag
That and then configure the root URL properly in your application (ghost).
awake avatar
ng flag
Thank you. So when I use `mydomain.de` as URL for ghost and change my config file accordingly, my domain provider displays a message that the page can not be reached and is telling me that the site has not been configured yet.
us flag
Have you configured the DNS records properly?
awake avatar
ng flag
Hey Tero, thanks for the patience. So if I check my DNS propagation with something like [DNS Checker](https://dnschecker.org) and enter my domain, my DNS apparently has propagated properly.
us flag
Do you see entries in your access.log when you visit the domain?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.