• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFHTTP problem with Host Headers

New Here ,
Dec 12, 2009 Dec 12, 2009

Copy link to clipboard

Copied

I am trying to post a form on a windows server using cfhttp.

The website relies on host headers to work properly (there are many sites on the server), but cfhttp posts appear not to send the required header information, returning a "No websites are configured" error message.

I've tried sending header info with <cfhttpparam type="header" name="host" value="www.mydomain.tld"> and it hasn't worked.

It may be important to know that the domain name is local only and relies on an entry in the hosts file, both on the browser machine and the server machine.

I have recently reconfigured the web server.  Previously, each site had its own IP address, but now they are all the same and using host headers.  Before, when each site had a unique IP, the cfhttp posts worked fine.

Is there a way to get them working in the host header configuration?

Thanks for replies.

- Don

TOPICS
Advanced techniques

Views

3.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 24, 2009 Dec 24, 2009

Copy link to clipboard

Copied

But hang on... host headers are a web server conceit, are they not?  The client agent (ie: <cfhttp> in this case) just sends an HTTP request to a domain name.  It's up to the web server to untangle which domain name goes to which website within its config.  All <cfhttp> needs to send is an HTTP to request to a valid domain, just like if I was typing in a URL in my web browser... the web browser doesn't need anything other than the domain name to reach the web server (assuming the domain name can be resolved into an IP address and get routed correctly, obviously).

?

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 25, 2009 Dec 25, 2009

Copy link to clipboard

Copied

I've tried sending header info with <cfhttpparam type="header" name="host" value="www.mydomain.tld"> and it hasn't worked.

Does this fare any better?

<cfhttpparam type="header" name="host" value="mydomain.tld">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Thanks for the reply.  Unfortunately, it doesn't seem to make any difference.

Any other ideas?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 12, 2010 Jan 12, 2010

Copy link to clipboard

Copied

Does IP address work as the value?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 13, 2010 Jan 13, 2010

Copy link to clipboard

Copied

Not sure if I understand why this might work.

Isn't the point of host headers to differentiate between multiple websites sharing a single IP?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2010 Jan 13, 2010

Copy link to clipboard

Copied

Not sure if I understand why this might work.
Isn't the point of host headers to differentiate between multiple websites sharing a single IP?

It is. This is just for elimination.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 18, 2010 Jan 18, 2010

Copy link to clipboard

Copied

Consider it eliminated!

The error changed though.  Instead of receiving a "no website configured" string from the CFHTTP call, I now get a ColdFusion error; "File Not Found" for the form at the target URL. (/forms/includes/form1.cfm).

This makes sense, as the IP address points to the default webroot (c:\inetpub\wwwroot) and not the site referenced by the host header (c:\websites\mysite).

Using host headers has saved time and IP configuration, and worked well for everything EXCEPT cfhttp calls.

Any more ideas?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 18, 2010 Jan 18, 2010

Copy link to clipboard

Copied

That got me thinking. Since you're local, have you registered the IP address and domain name in the /etc/hosts file?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 19, 2010 Jan 19, 2010

Copy link to clipboard

Copied

Yes, absolutely. The hosts file is accurate and identical on both the workstation and (more importantly, in this case) the server.

I think that is an indicator of the problem: Whatever web server is responding to the CFHTTP request doesn't seem to consult the hosts file. I've presumed that is IIS (IIS-5 on Win2k) but perhaps not.

The reason I say "perhaps not" is that IIS does in fact successfully consult the hosts file for HTTP requests that come from the workstation or its server console. Why wouldn't it check the hosts file when responding to CFHTTP? I have another server running IIS-6 and will give it a try also.

So far, I can't seem to find the magic.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2010 Jan 19, 2010

Copy link to clipboard

Copied

The hosts file is used by the machine initiating TCP/IP communications to resolve an IP address from a domain name.  It's not used by the server to resolve a domain name from incoming HTTP requests (how could it: many domain names could map to the same IP address?).  The hosts file is a TCP/IP conceit; host headers are an HTTP conceit.  They are only loosely related in that HTTP is transported over TCP/IP.

On your client some agent makes a request to a domain name (this can be any TCP/IP protocol, not just HTTP).  The hosts file is checked to see if the domain name has a mapping, and if it does, the request is routed to that IP address.  If there's no entry, then the standard DNS look-ups are made, and the IP address is found that way.  But that's the only involvement in the request (or any sort of routed traffic) that the hosts file has.

Can you replicate this behaviour with <cfhttp> requests and other web servers, or is it just that one?  IE: can you set up a web server in the lab which has the same web site / host header config, and see the same problem when making <cfhttp> requests?  Does the web server log failed requests like this?  Usually IIS's logs are website-centric aren't they?  And if the request is not making to a web site, is it logged some other way?

Can you inspect the incoming request to see if any of the headers are bung?

Are you sure your host header for your website has the exact domain name the <cfhttp> request is... err... requesting?  And that you're making the request on the same port, and IP address as the host header is configured for?

I really doubt <cfhttp> is the culprit here - at least in the way you're suggesting - because almost every web server in existence will be serving more than one website, and it's not like <cfhttp> usually has this problem...

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2010 Jan 19, 2010

Copy link to clipboard

Copied

Oh, and what happens if you set a userAgent string to reflect "common" browser?  I've had web sites set to reject requests coming in from dodgy-looking user agents, and indeed have refused requests from <cfhttp> (which passes a User-Agent value of "ColdFusion").  I usually get a different error than you're seeing though... I don't recall what it is, but it's not what you're seeing.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 19, 2010 Jan 19, 2010

Copy link to clipboard

Copied

Adam -

Thanks for your flurry of very valuable ideas. I'll work my way through them and update this thread.

Thanks also for your obscure and interesting usage of the word "conceit", which sent me to the dictionary - something I always enjoy.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2010 Jan 19, 2010

Copy link to clipboard

Copied

Thanks also for your obscure and interesting usage of the word "conceit", which sent me to the dictionary - something I always enjoy.

Haha, cool.  You're welcome.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 19, 2010 Jan 19, 2010

Copy link to clipboard

Copied

My thanks. The problem is resolved.

In the end, I think I was sending a trailing slash with the domain name in the host header.

Embarrassing, yes.

Again, thank you for your (and BKBK's) assistance.

- Don

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2010 Jan 19, 2010

Copy link to clipboard

Copied

LATEST

Nah, not embarrassing.  For all the confidence in my post about TCP/IP and HTTP before, I had to go read up on the protocol stacks and how they worked, and do some experimentation with <cfhttp> and Firefox and pick apart some HTTP requests and such like.  I thought I new how it all worked when I sat down to reply, but I was really wrong in some of my assumptions as it turns out.  So it was a good learning experience for me too.

It's always easy in this sort of thing to mix up what's a domain name (no slashes) and what's part of a URL (can contain slashes obviously), and I bet everyone has done what you just did at least once.  I know I have.

Take it easy.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 19, 2010 Jan 19, 2010

Copy link to clipboard

Copied

Let cfhttp post to the full URL of the form page, http://www.mydomain.tld/forms/includes/form1.cfm

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation