So, you have a case of an "NGINX Has Only One Site Configured" problem. That is, NGINX is serving the same data not just for your domain but for the bare IP address and any other request to your server/site (even with invalid domains - domains/subdomains which are NOT hosted on your site).
Thankfully, this is something you can fix.
FIRST we need to have a 'catch-all' to just drop non-valid domains and direct-to-IP requests. We'll redirect them all to your proper domain.
server {
listen 80 default_server;
server_name _;
return 301 https://mosachi.ga$request_uri;
}
SECOND we need your config for your domain, but with a few tweaks (you shouldn't have server_name localhost;
if you intend to serve an actual domain):
server {
listen 80;
server_name mosachi.ga;
return 301 https://mosachi.ga$request_uri;
}
server {
listen 443 ssl;
server_name mosachi.ga;
ssl_certificate /etc/letsencrypt/live/mosachi.ga/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mosachi.ga/privkey.pem;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Combined, your configuration should look like this:
# Catchall configuration - redir to the domain for bare and invalid domain requests
server {
listen 80 default_server;
server_name _;
return 301 https://mosachi.ga$request_uri;
}
# HTTP handler to redirect to HTTPS for mosachi.ga
server {
listen 80;
server_name mosachi.ga;
return 301 https://mosachi.ga$request_uri;
}
# HTTPS for mosachi.ga
server {
listen 443 ssl;
server_name mosachi.ga;
ssl_certificate /etc/letsencrypt/live/mosachi.ga/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mosachi.ga/privkey.pem;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
It may take some time for Google to play catchup here, but eventually the IP will just disappear from the search data, and the domain itself will show up in the search results instead.