determining the address of the server? |
The way my app has been designed is that each server has a copy of wordpress, copy of the application, and a copy of the fusionAuth server. When a user reaches my website, researchStudyOnline.com, the AWS load balancer determines which server will be handling this request by displaying my landing page. My landing page has a button: Login to Research Study Online. This will bring them to my app at a certain URL on that server.
On my laptop "server" the address of the server is localhost. So to login they get sent to localhost/index.php/Login. Bur how will this work on my AWS server? Will localhost still be the local server or will I use xx.xx.xx.xx/index.php/Login?
proof that an old dog can learn new tricks
On live servers localhost is usually used for MySQL servers so you would need to use the full url address.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
There is a problem. Each server (this is designed to handle a few) will have a different address. But the code running on all of them is the same. I'm seeking a CI function that returns the IP of the current server. Then I can use a var called server_address instead of the hard coded address.
proof that an old dog can learn new tricks
@richb201,
Try experimenting with the following to find the Server parameters. I would also prevent rendering the details unless a certain $_GET value is verified to prevent others from seeing sensitive server information. PHP Code: // pre adds line-feeds for easier readability
I think the SERVER_ADDR parameter applies to the Internet Service Provider.
Try the REQUEST_URI parameter.
I tried $IP=$_SERVER[REQUEST_URI];
and this yields /index.php/Configure/index
proof that an old dog can learn new tricks
on my local dev I have a web dev thats configured to be served on 127.0.0.2
if i put this code in a controller : Code: $IP2= strval($_SERVER['SERVER_ADDR']); it correctly returns 127.0.0.2
@rich2b01,
I have a similar app that at the user point of entry tests for the environment URL, defines a constant then requires a common application. The common application uses the defined constant and sets the relevant MySQL database tables, paths, etc.
He is on AWS and some people have reported problems trying to get the host address see below.
PHP Code: // From PHP.net - gethostbyaddr() You should be careful in the use of $_SERVER['HTTP_X_FORWARDED_FOR'], as I discovered, once using Amazon AWS's Elastic Load Balancer's, this value may be a comma separated list of IP addresses and will thusly not compare as conceived in almost every example I have seen posted by users in the comments. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |