Using Application Variable Based on Server's IP Address

Discussion in 'Programming' started by forumposters, May 4, 2007.

  1. #1
    Is there a way to detect the ip address of the server and if it's the production ip address, then create an application variable for an image directory that points to a remote directory (in this case, Amazon's S3 server), and if it's the dev ip address, then set the image directory to the local directory.
     
    forumposters, May 4, 2007 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try the GetHostAddress() function at http://www.cflib.org/udf.cfm?ID=446. If you can use server name, look into CGI variables.

    
    <cfoutput>
    CGI.SERVER_NAME=#CGI.SERVER_NAME##CGI.SERVER_PORT#<br />
    CGI.HTTP_HOST=#CGI.HTTP_HOST#<br />
    </cfoutput>
    
    <!--- show all available --->
    <cfdump var="#CGI#" />
    
    Code (markup):
     
    cfStarlight, May 4, 2007 IP
  3. forumposters

    forumposters Peon

    Messages:
    270
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm not sure that is what I need actually. I need a function that will get the ip address without passing in a domain name or anything like that.
     
    forumposters, Jun 18, 2007 IP
  4. Paul_Hopkinson

    Paul_Hopkinson Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    #cgi.remote_addr# is what you need to get the IP address
     
    Paul_Hopkinson, Jun 18, 2007 IP
  5. Robocoder

    Robocoder Guest

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Actually cgi.remote_addr is what you use to get the client (remote) ip address.

    Under IIS 6.0 and CF8 you can use this to get the IP Address that the client request came in on (ie. the server IP address)

    #cgi.local_addr#

    Hope this helps!
     
    Robocoder, Sep 30, 2008 IP