| [<--Prev] [Next-->] | ||
| [Printable Version] [Search: ] [Daryl's TCP/IP Primer] [Daryl's ColdFusion Blog] |
![]() |
The following questions were posed to me by some means: usually directly, or to some mailing list I lurk on. Last names and/or Internet addresses have been changed to preserve anonymity of posters.
|
Q: I have a Pentium III with 256 Meg ram and a brand newly installed Windows NT Server software loaded operating system and all. I am using Microsoft IIS as well. I can get the web browser to work through localhost. However, when I try to access CF Administrator I have two problems. a. CF Administrator wants to use the 127.0.0.1 path which apparently is not working properly. b. The [ColdFusion Administrator] will not start. These problems are probably interrelated but need suggestions on what to look at under the hood as it were. It seems that 127.0.0.1 is not working and it should. |
|
A: Please understand that this is an IIS problem, not a ColdFusion problem. If IIS is not configured correctly, then CF will not behave well, since it /depends/ on the Web server process (be it IIS, Apache, Netscape Web Server, or any other) to properly forward requests to the ColdFusion server service. Before you ask, that's a "feature", since it allows ColdFusion to coexist on the server with other Web server technologies, such as Java, Perl, or even...ASP. While you have a physical Web server computer with a physical NIC at a given IP address, for example 192.168.1.1, it's important to understand that there is always another "virtual" NIC, known as the "loopback adapter", at the IP address 127.0.0.1, with a "HOSTS" file alias of "localhost". This is not a Windows NT invention, but rather a standard (and required) property of any TCP/IP protocol stack. Windows, however, does the unusual [dis]service of hiding the virtual NIC when you type "ipconfig" at the command prompt. If you type "/sbin/ifconfig" at a RedHat Linux command prompt (location of ifconfig may vary with other Linuxes/Unixes), you will see the loopback adapter, with the IP address of 127.0.0.1. Traditionally, multiple Web sites are hosted on a given Web server by assigning several (or many) IP addresses to one physical NIC. Then, the Web server software is configured to point requests arriving at a given IP address to the file system directory that contains the root of the site: by default, IIS associates "(All Unassigned)" IP addresses to the \Inetpub\wwwroot\ directory on the drive. What you do from there is what can "break" ColdFusion. Web browsers will typically send the name of the server they are trying to connect to-- whatever name the user typed in. This is accessible in ColdFusion as CGI.HTTP_HOST. (All of the CGI variables that begin with "HTTP_" were sent as "request headers" by the user's browser. The Web server software then prepends "HTTP_" before making the values available.) Since virtually all browsers now send the HTTP_HOST name it was connecting to, some ISPs use that information to determine which Web site is presented to a user. This is known as using "host header" information to multiplex Web sites on a single IP address. If you are using "host headers" under [IIS Web Site Properties] / [Web Site] / [Advanced] / [Add] / [Host Header Name] to run multiple virtual Web servers on a given "real" IP address (in this case 192.168.1.1), you should also include a mapping for the "administrative" web site that contains the /cfide/administrator directory so that it responds to both the "localhost" host header and its corresponding IP address, 127.0.0.1. |
|
Q: I am having some strange things happen with CFMAIL - I setup a system for our HR department to upload and email new vacancy bulletins. The CFMAIL goes through a database, and sends an email, with a file attachment. The problem is, our email system properly recognizes the From: part of the message.. my main home email server, and hotmail receive it as Sender Unspecified while another server I have an account on correctly receives the From: Any Idea what might be causing this? I am using our FireWall as an SMTP server since the GroupWise SMTP agent would not accept connections. |
|
A: One oft-overlooked smart-relay solution is to install the Microsoft SMTP server service that is part of Option Pack 4. Set up the SMTP service to relay mail for 127.0.0.1 (buried somewhere in MMC), then configure ColdFusion to send mail to 127.0.0.1 (in the usual place in CF Administrator). This requires that the ColdFusion server has access to the DNS of the real world, and that the server can make outbound connections through the firewall to port 25 on remote systems (neither of which is usually a problem.) To test this: DNS test: nslookup > set type=mx > hotmail.com[a list of servers should appear] > exitSMTP test: telnet mail.hotmail.com 25You should see: 220-HotMail (NO UCE) ESMTP server ready at Wed, 31 May 2000 20:45:27 +1700 220 ESMTP spoken here I have used this solution before with no problems (once I found the right place in MMC to allow SMTP relaying.) |
|
Q: I decided that today I would learn cookies - but they are kicking my butt all over the place! I have a simple Cookie thingy setup just as an easy example (to see if I could get them to work, mostly) [URL Removed] that form asks for a username and password, the action on that form goes to cookie1.cfm which has this as the source: <cfcookie name="logintest" value="Logged In"> <cfcookie name="login" value="#FORM.uname#"> <cfcookie name="pass" value="#FORM.password#"> <cflocation url="cookie2.cfm">Cookie2.cfm has this in the body:
<CFOUTPUT>
<cfif IsDefined("Cookie.Login") IS "True">
#Cookie.login#
<cfelse>
No cookie!
</cfif>
</CFOUTPUT>
And all I get is, "No Cookie!" if I take out the <cfif> statements, it tells me cookie.uname does not exist. What am I doing wrong?? |
|
A: Simple: A page has to load in order for cookies to be added to the browser. <CFLOCATION> preempts the page content, so no cookies are set. You can't use <CFCOOKIE> and <CFLOCATION> on the same page. However, you can set a cookie then do a redirect by using CFCOOKIE as normal, then using the following code to redirect to (for this example) logonFailed.cfm:
<cfheader name="location"
value = "logonFailed.cfm?ffMessage=#urlEncodedFormat("Invalid password for #ffUserName#")#">
<cfheader statusCode = "302" statusText = "Document Moved, Dude.">
|
|
Q: I'm having problems getting certain documents using CFHTTP. Are there any alternatives? |
|
A: Leverage ColdFusion's excellent Java integration by implementing a Java class for this purpose:
<cfobject action = "Create" type = "Java"
class = "HTTPClient.HTTPConnection" name = "httpConn">
<cfscript>
httpConn.init("www.cfprimer.com");
response=httpConn.Get("/");
content=response.getText();
</cfscript>
<cfoutput>
#content#
</cfoutput>
For another example of Java integration (and more depth), see my DevCenter article at
http://www.allaire.com/handlers/index.cfm?ID=22250 .
|