Uly.me

cloud engineer

  • Home
  • About
  • Archives
Home/Cloud/CodeIgniter Base URL

September 19, 2019

CodeIgniter Base URL

I have a CodeIgniter dev site in Google Cloud. The instance obtains a new IP address at every start. You can set the base URL to a domain or IP address in the “/application/config/config.php” file. Since it’s only a dev box, I don’t have a domain assigned. It’s accessible via IP address only which changes every time the instance is started. So here’s the workaround. I added some extra code in the config file to obtain the external IP address.

$realIP = file_get_contents("http://ipecho.net/plain");
$config['base_url'] = 'http://'.$realIP;

$realIP = file_get_contents("http://ipecho.net/plain"); $config['base_url'] = 'http://'.$realIP;

The code is using a service from ipecho.net which returns your external IP address. Works like a charm!

Filed Under: Cloud Tagged With: base url, codeigniter, dev, dynamic, gcp

Content delivered to your email

About Me

I'm Ulysses, a Cloud Engineer at Cardinal Health based in Columbus, Ohio. I’m a certified AWS Solutions Architect. This website is my way of documenting the things I have learned in the Cloud. When off the grid, I enjoy riding my electric skateboard. I have surfed, snowboarded and played the saxophone in the past. I hope you will find this site helpful. It's powered by WordPress and hosted in AWS LightSail.

  • Cloud
  • Linux
  • Git

Copyright © 2012–2021