WebFaction
Community site: login faq

I have several Webfaction machines. I'd like to serve most of the website from one machine and the "/media" url path from another machine.

Is this possible?

So far I'm seeing that if I serve "/" and "/static" from one machine, then configure "/media" to serve from another machine, the "/" and "/static" traffic switches to the second machine even though it's not defined that way in my control panel.

When I look at the Domains in my control panel, it shows what I defined: one entry serving from web428 for "/" and "/static" and another entry serving from web462 for "/media". However, when I look at the Domains page, it shows that my domain is being handled by the web462 Website definition (which was defined second). So it looks like the configuration of the Website for the second machine overwrote some of the settings in Domains and the control panel is not able to fully and accurately display my configuration.

asked 14 Aug '14, 00:03

heliodor
306
accept rate: 100%

edited 14 Aug '14, 00:04


No, that's not possible.

The reason is that which machine a site is served by is determined by the domain, not the URL. By setting the website configuration up as you have done, with "/" using one machine and "/media" using another machine, what you've really done is told our DNS servers that you want your domain to resolve to both servers simultaneously.

That creates round-robin DNS, and more information is available in our documentation here. The most important point thing with respect to this problem however is that the DNS resolution (and determination of which server the HTTP request will be sent to) is determined first, before the request is actually sent. If the domain resolves to two servers, then the server that the request will be sent to will be determined randomly.

This means that clients will randomly determine which machine to send HTTP requests to, regardless of the URL, because DNS is a property of domains only (and DNS says nothing about URLs). About half of the requests will arrive at the "correct" server for the "/media" URL, but the other half will arrive at the wrong server. If you only configure one server to handle that URL, then only half of those requests will work, and your website will probably be very broken.

So, instead of configuring URLs to differentiate between servers, you'd want to use different domains instead. You could create something like "mydomain.com" and "media.mydomain.com", each of which resolves to a different server, and then use URLs that exist in each respective location.

Hope that clarifies!

permanent link

answered 14 Aug '14, 00:25

ryans ♦♦
5.0k93159
accept rate: 43%

After some testing, I see that this domain rule uses both the http and https Websites that are defined, so if you want to create an app to redirect http to https for your subdomain, make sure that app resides on the same machine as the app handling the subdomain.

(15 Aug '14, 18:06) heliodor
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×29
×24
×4

question asked: 14 Aug '14, 00:03

question was seen: 2,051 times

last updated: 15 Aug '14, 18:06

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM