Solved

Utilizing client URL information?

Posted on 2002-06-10
10
142 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
 

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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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 150 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now