Hi everyone imagine: i have a site and two servers that one of them is located (for example) in New York city and other one in Washington. I want to download some pages of site from New York server and other ones from Washington server. how can i do this ? Thank you in advance.
Are you talking about load balancing? As in you want half your users to use the New York server and the other half to use the Washington server?
No tonybogs , the contents of the site (pages) divide into two sections. one section is on New York server and other one is on Washington server. in fact when the user wants to visit the site, some pages download from New York and other ones download from Washington.
You can do two things: * User different domains, aka: www.domain.com , domain.com * Use IP address of server instead of domain name Peace,
You could also take this approach, use 2 servers: www.domain1.com (new york) www.domain2.com (washington) Use domain1 server as the master, all incoming requests go to this server. If a page example.php is requested on domain1 you can just include the file via http from domain2. <?php include('http://www.domain2.com/example.php'); ?> If you are handling all incomiong requests through 1 file like index.php this should be easy as all you'll need to do is check if the file exists. If it doesnt include it from server 2. As a note though, this will only work if you have allow_url_fopen enabled in your config. Hope this helps
If at all possible, I would avoid this scenario like the plague. While tonybogs example will definitely work, I am having a very hard time seeing why you would want to set up your boxes like this. I guess if you have content that is owned by someone else that resides on there box and you need access to it. If you have the choice, mirror the two boxes. If one box fries, then you are not out half your content! It would be a matter of buying a new box and mirroring back your site image. You don't want to set up a true master/slave setup either. There is no need to be constantly bouncing traffic up and down the Eastern seaboard. Remember that this will only add to bandwidth costs. Go with load balancing. Best way to go. Two mirrored boxes for redundancy and a load balancer. If you have the money, check out F5 Networks. They make some great stuff. Plus after the dot.bomb, you can get surplus stuff on eBay dirt cheap (like 90%+ off!). Good luck with your project!
thank you tonybogs for your suggestion(including), but i'm sorry, my question was changed(just a little) because it is my friend's question. i said "some pages" but in fact "some files" like jpg,exe,rar and etc.must download from Washington server and other ones from New York server.it is an upload center. for example : mehdiali/files/a.exe (it is downloaded from Washington server) mehdiali/files/b.exe (it is downloaded from New York server) what is your idea about using .htaccess(it is a file that locate in folder in apache and you can write some commands. and according them apache do something). or is there any tools in operating systems that if there isn't requseted file in one of them send a message(request) to another operating system and get it.
I have website which provides free mobile stuff. Site is full of downloadable contents. In situations of too many simultaneous request from visitors, my visitors face either broken download or page unavailable. So i decided to share server load into two servers. Now i purchased two hosting accounts from different companies and uploded all data on both servers. Now i have one website name and two different dedicated IPs. Now problem is that i want to share load between two servers. If there are two simultaneous requests it should be handled one by server A and second by server B. I dont have enough knowledge to configure load balancing between two servers for my site. Kindly write down complete procedure. Thanks in advance.
host all images/content on server 1/domain 1 have all pages/etc with hotlinked content on server 2 ( hotlinked content is on server 1 )
1. Last news : I don't know name of the files. 2.I got something from http://www.thephpforum.net : set this in your .htaccess ---------Start---------- # to make exe force to download AddType application/octet-stream .exe #redirect your request to paticular server Redirect 301 /files/a.exe http://Washingtonserver-path/a.exe Redirect 301 /files/b.exe http://NeWYorkserver-path/b.exe -----------End--------- place the .htaccess file your both server _________________ Thanks, Muthukumar Selvarasu, Project Manager, Webmasters Ltd. 3. but because i don't know the name of files i can't use it. if you can change it as i can use it please send your suggest. 4. joebert, a member of apache forum of own site : Your best bet will be asking in relevant OS forums about setting up network shares on server B so server A can setup aliases & treat those server B shares like directories. Then you can either setup a download script that checks the current location followed by the remote location for each request, or setup a 404 script that checks the remote location only in the event the current location doesn't have the file. 5. when we use 404 script , it redirect www.mehdiali/files/b.exe to another server without files/b.exe so b.exe will not download.
Since you're dealing with media content, it may prove beneficial to use a CDN. A CDN will automatically use GeoIPLocation to select the right server for your visitors. Although CDNs do cost money to use (usually per GB/TB transfer), they really offer high speed for your premium users. A Google search for Content Delivery Network will prove useful for this purpose: http://www.google.com/search?hl=en&q=Content+delivery+network&btnG=Search This is very possible, too. All you need to do is specify static routes to these servers. ~Joe
thank you for your replies, the solution : the user type mehdiali/files/b.exe(requested_url) that isn't available in server A. so i must redirect it to server B. i write a command like this in htaccess file : ErrorDocument 404 "http://localhost/divider.php?r_u=requested_url" so in divider.php page i have $HTTP_GET_VARS['r_u'] and after fetching the b.exe(file name) i'll redirect it to server B, like this : header("location:mehdiali2/filename/b.exe"); but my problem is how i can find requested_url. what do you write instead of requested_url in ErrorDocument 404 "http://localhost/divider.php?r_u=requested_url" is there any variable? i don't know the name of the files. please send the complete code.
hi thanx mehdi i use this code in htaccess to redirect with all request url ewriteEngine On RewriteRule upload/(.*)$ http://server2.com/upload/$1 [L] Code (markup): but i think we can use this code when 404 error return
the code redirects http://A/files/b.exe to http://B/files/b.exe if b.exe is not in server A type this code in your htaccess file : ErrorDocument 404 "<html><body> <script language =javascript> url= window.location;<!--current URL url = url+'';<!--convert it's type to string slash_location=0; <!--this while is using for extracting the file name <!--i mean : http://A/files/b.exe that isn't in server A while(slash_location!=-1) { end_slash_location= url.search('/'); url=url.substring(end_slash_location+1,url.length); slash_location=url.search('/'); } <!--here value of URL is b.exe window.location='http://B/files/'+url; <!--redirect it to server B </script> </body></html>" Note: 1.ErrorDocument 404 command: ErrorDocument 404 is a event that arise when "Page can't be displayed" and then the command is executed. 2.all of the mentioned code must be in one line. 3.ErrorDocument 404 " you can't use double quotation in this area ". 4.the script must locate just in one of the servers(in this case in server A).