Browser shows IP address instead of my domain name when using Google Cloud

5,792

Solution 1

Are you running just the one site from Google Cloud? If you're using the default Apache config, on some distros it will set up one virtual host using the IP address as the name. Any other requests would be then diverted to that default virtual host, hence you end up at your IP address.

Solution 2

If you type in your domain, and it ends up on your IP, then that means it's being redirected. Look for a .htaccess file or a setting in Google cloud which is redirecting it. Perhaps Google cloud needs to be told what domain it will be serving for your IP? Use curl -I www.example.com to see the headers and redirects

Share:
5,792

Related videos on Youtube

sus
Author by

sus

Updated on September 18, 2022

Comments

  • sus
    sus over 1 year

    I recently bought a domain name from GoDaddy. I have a web server running in Google Cloud with a static IP. In the DNS configuration in GoDaddy, I added an A record (@ -> To the static IP of the Google Cloud server) and also a CNAME record for www to point to @.

    When I go to www.my_domain_name.com (or my_domain_name.com), I can see my website with no issues. However, the browser shows the IP address instead of www.my_domain_name.com. Almost all posts on the internet suggest that I add an A record, which is already added in my case.

    Update:

    Here is what I get when I issue curl -I www.mydomain.com:

    HTTP/1.1 302 Found
    Date: Thu, 29 Jan 2015 08:47:43 GMT
    Server: Apache/2.2.22 (Debian)
    X-Powered-By: PHP/5.4.36-0+deb7u3
    Set-Cookie: osclass=j20ouo6i8lvmmu88rf68j6clp7; path=/; HttpOnly
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    Location: http://130.211.241.199:/
    Vary: Accept-Encoding
    Content-Type: text/html
    

    And this is the content of my .htaccessfile.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
  • sus
    sus over 9 years
    Thanks! I updated the question with curl output and htaccess file contents. Could you please have a look and let me know whether they look OK? I am fully new to web hosting and does not understand much of it.
  • Chloe
    Chloe over 9 years
    Well I'm not too familiar with Google Cloud so I don't know the options for it, but it is definitely redirecting to the IP address because of this line: Location: http://130.211.241.199:/. It's not because of your .htaccess but there might be an option in the admin panel to cause this.
  • sus
    sus over 9 years
    There has been an issue with huwamaru.com, www.huwamaru.com worked. If you check now, both of them work. Should't the name server resolve the domain name to IP address, so that the browser can find the host?
  • Chloe
    Chloe over 9 years
    Yes, both www.huwamaru.com and huwamaru.com should resolve to the same IP address. Add an A record to huwamaru.com and CNAME record for www subdomain to point to @ (which means the root domain, huwamaru.com). Try to update your question with a screen shot of the DNS host configuration screen.