Block an IP in Coldfusion

How do I block a specific IP address from accessing a website.
Gregory AmbroseAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

erikTsomikSystem Architect, CF programmer Commented:
try these steps
Log into the .htaccess Editor, and then click Block IP Addresses.
Select the directory from which you want to block access. ...
To add a new IP address or range, enter it in the designated field.
Click Save to save your settings. ...
To delete an IP entry, click the delete icon in the Blocked IP Addresses/Ranges table.
erikTsomikSystem Architect, CF programmer Commented:
The coldfusion way...

<cfif cgi.REMOTE_ADDR is "">
      Go Away!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

erikTsomikSystem Architect, CF programmer Commented:
I would not rely on CGI variable because they can  easily be  manipulated. But as general rule I would  use the suggestion
Gregory AmbroseAuthor Commented:
Thanks for the Coldfusion solution; I could get the .htaccess solution to work.
@Gregory Ambrose - You have several options depending on the environment you are working in. For example,
Is the site hosted on a Windows or LINUX based server?
Is the site on a local intranet or public facing Internet?
Is the server managed in-house or by hosting provider?

Yes, you can leverage CF to block specific IPs or range of IPs. However, you have to maintain the list if the IP changes.
Gregory AmbroseAuthor Commented:

The site faces the public on a windows server provided by a hosting company.
@Gregory Ambrose - If you suspect malicious user(s) via Internet traffic, then your best defense might be to have your hosting provider block the suspect IP range. Sometimes the control panel tools for management of your site allow you to perform this task yourself.

In addition to @gdemaria solution, you could add an application enhancement that captures the client IP in a table after certain conditions are met. Then use some sort of UDF, OnRequest, code to automatically restrict site access if the IP address was logged...
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.