Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Utilizing client URL information?

Posted on 2002-06-10
10
Medium Priority
?
184 Views
Last Modified: 2013-12-24
I have a need to check if a client is accessing our site from the internet or our intranet. I am running IIS 2000 Server and ColdFusion 5.0 server in the DMZ. I would like to compare the client URL to our known network URLs and put an "CFIF" clause. If the client is an intranet client I want to display different text than if the client is an internet client. Does anyone have a CF code or JavaScript sample that would do this?
0
Comment
Question by:apwbe
  • 5
  • 5
10 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 7068673
Client's URL or IP address?  I don't think can simply access the Client's URL.

What you should do is use
CGI.remote_host or CGI.remote_addr

These will return the client's IP address.

Now you can use these to validate the clients connecting to your site instead of the URLs.

If you must URLs you can use the IP address to do a reverse DNS lookup and get the server name and then check it.

Another option, the better way to do this... is to use a reverse proxy on your server.  You can setup a reverse proxy to allow/deny various ip addresses or subnets.  This is easy to setup and a lot better than using code.

HTH,
CJ



0
 

Author Comment

by:apwbe
ID: 7068683
I am sorry. What I need is to compare a substring (the first 6 characters) of the client IP address. I have one CF page that needs to know if the client is internet or intranet as different text will be shown. Basicaly:

If IP.sub(0,5) = 180.40
    "you are Intranet"
else
    "Your are Internet"
End If

I know the syntex is goofy but  I hope you get the idea. I do not want to limit a whole page, just make a decision based on the client IP.

I do not know if a reverse proxy will do what I wnat it to do.

what do you think?
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7068702
try this:
<cfif Left(CGI.remote_addr, 6) IS "180.40">
     You are accessing this page from the intranet.
<cfelse>
     You are accessing this page from the internet.
</cfif>

or try this:
<cfif FindNoCase("180.40", CGI.remote_addr, 1) EQ 1>
     You are accessing this page from the intranet.
<cfelse>
     You are accessing this page from the internet.
</cfif>

HTH,
CJ
0
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

 

Author Comment

by:apwbe
ID: 7068750
The FindNoCase seems to work. Here is what I am trying.

<cfif FindNoCase("10", CGI.remote_addr, 1) EQ 1>
    You are accessing this page from the intranet
<cfelseif FindNoCase("192.168", CGI.remote_addr, 1) EQ 1>
     You are accessing this page from the intranet
<cfelseif FindNoCase("172.16", CGI.remote_addr, 1) EQ 1>
     You are accessing this page from the intranet
<cfelse>
    You are accessing this page from the internet.
</cfif>

I will test it from home later tonight. If I wanted to display the IP address, how whould I do that?
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7068758
eq 1 means it starts with that address, so do you have 10 as a start of the ip addy?

to display the address add this:

<cfoutput>Client's IP Address: #CGI.remote_addr#</cfoutput>

CJ
0
 

Author Comment

by:apwbe
ID: 7068759
The FindNoCase seems to work. Here is what I am trying.

<cfif FindNoCase("10", CGI.remote_addr, 1) EQ 1>
    You are accessing this page from the intranet
<cfelseif FindNoCase("192.168", CGI.remote_addr, 1) EQ 1>
     You are accessing this page from the intranet
<cfelseif FindNoCase("172.16", CGI.remote_addr, 1) EQ 1>
     You are accessing this page from the intranet
<cfelse>
    You are accessing this page from the internet.
</cfif>

I will test it from home later tonight. If I wanted to display the IP address, how whould I do that?
0
 

Author Comment

by:apwbe
ID: 7068765
Yes,

I have one that starts with a 10.x.x.x that I have to compare then I have one that starts with 192.168.x.x that I have to compare and lastly 172.16.x.x hat I have to compare. If the IP address starts with any of these then it is intranet else internet.

0
 
LVL 19

Accepted Solution

by:
cheekycj earned 600 total points
ID: 7070174
how did it work out?

CJ
0
 

Author Comment

by:apwbe
ID: 7071359
cheekyci,

Thanks for the help. Actually oth sample seem to work for what I want. Keep up the excellent work and thanks again.

Good Luck,

Warren
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7071369
Glad I could help and thanx for the "A"

CJ
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question