Sign in to follow this  
Followers 0
mediator

Redirect server traffic locally

35 posts in this topic

While true you can not have them all listen on port 80 on the same IP.. You can just give the box more than 1 IP and have the different IPs listen on 80..

Share this post


Link to post
Share on other sites

Yeah VirtualBox or VMware or something like that :p

While true you can not have them all listen on port 80 on the same IP.. You can just give the box more than 1 IP and have the different IPs listen on 80..

Share this post


Link to post
Share on other sites

No.. You don't need virtual box or VM.. You an have pretty much as many IPs you want on 1 box (OS) physical or virtual machine. Even windows allows multiple IPs..

For example you could have 192.168.1.100, 101, 102 all the same OS and have apache/IIS bind siteA to .100, siteB to .101, siteC to .102 -- Where it gets tricky is since you only have 1 public IP (normal home user atleast) you have to run a reverse proxy to forward to the different internal IP based upon host headers.

Share this post


Link to post
Share on other sites

Use CloudFlare if you can.

Their DNS can do redirects

Share this post


Link to post
Share on other sites

"Their DNS can do redirects"

 

This is my point --- DNS does NOT do redirects..  This statement as stated is FUD!!!!

 

You can say that cloudflare provides a redirect service, but saying that DNS has anything to do with is not correct.

Share this post


Link to post
Share on other sites

Hi All, I'm sorry for the late visit this time. Creating a fight was never my intention. I apologize.

 

Anyways, I think I need to be clearer. Now, I don't intend to create multiple domains (like www.site1.com) on my own IP(10.5.5.5). The domains will be given by providers like godaddy and they will map the domains to the given IP (10.5.5.5). What I really want is conversion of traffic coming from these sites to different folders on 10.5.5.5.

 

A simple analogy could be - Chinese, japanese, Americans (site1,site2,site3) all land up in India (10.5.5.5). But I look at their passport on the Indian terminal, identify them and send them to different hotels as per my like.

 

My problem is to redirect the traffic locally. I need to point to a specific folder for each traffic condition. All these folders in my example i.e myfolder1, myfolder2, myfolder3 are on 10.5.5.5 only and 8080 port is being used. But I need to be folder/directory specific as well.

i.e Traffic Redirected from different sites should land on respective folders containing different web projects on the same IP.

Traffic from Site1 to 10.5.5.5 -> http://10.5.5.5/myfolder1/index.php    ( i.e If people open site1 on godaddy e.g www.site1.com, then myfolder1 on 10.5.5.5 should be activated ) 

Traffic from Site2 to 10.5.5.5 -> http://10.5.5.5/myfolder2/index.php    ( i.eIf people open site2 on godaddy e.g www.site2.com, then myfolder2 on 10.5.5.5 should be activated )

Traffic from Site3 to 10.5.5.5 -> http://10.5.5.5/myfolder3/index.php    ( i.e If people open site3 on godaddy e.g www.site3.com, then myfolder3 on 10.5.5.5 should be activated )

Site1,2,3 are just redirecting sites. These could be domains given by godaddy, yahoo or any other domain site. The traffic from these sites is redirected to my IP i.e 10.5.5.5 by the domain providers themselves. This is not my headache. Now it is here on 10.5.5.5 that the traffic shall be identified (locally) and redirected to myfolder1,2,3 respectively i.e there needs to be some mechanism on 10.5.5.5 which locally redirects to respective folders as stated above!

 

10.5.5.5 has been used for example purpose only, it is class C IP only in reality and I can do port/IP redirect via IPTables, but I need to be folder specific as stated above.

Share this post


Link to post
Share on other sites

Hi Budman and everybody, thank you for your time. I have set up the test environment. @Budman, I have followed your link and here it goes

 

Machine1 (which is equivalent to godaddy website lets says "www.home.com")

 

1. This has IP - 192.168.1.3

2. Here I have modified /etc/hosts with "192.168.1.2             www.home.com"

3. I will type on the web browser of machine1 "www.home.com"   (This should open up the desired folder/documentroot on 192.168.1.2)

 

Machine2 (which is equivalent to local system as in my problem statement)

1. This has IP - 192.168.1.2

2. Here I have used the following configuration

 

File : /etc/httpd/conf.d/test.conf


DocumentRoot /var/www/html/test_site
Alias /test_site /var/www/html/test_site
<Directory /var/www/html/test_site>
RewriteEngine On
RewriteBase /test_site/
RewriteRule ^index\.htm$  welcome.html
</Directory>

NameVirtualHost 192.168.1.2
<VirtualHost 192.168.1.2>
ServerName www.home.com
DocumentRoot /var/www/html/test_site
ScriptAlias /cgi-bin/ /www/hosts/www.customer-1.com/cgi-bin
</VirtualHost>

 

Now the problem is I cannot open the desired folder if I hit "www.home.com" on machine1.

Share this post


Link to post
Share on other sites

what http server are you running for starters.. Thought you said you were running tomcat?

 

@Sammy - I'm using Tomcat

 

http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html

 

WTF is machine 1 as godaddy?

 

"3. I will type on the web browser of machine1 "www.home.com"   (This should open up the desired folder/documentroot on 192.168.1.2)"

 

Yes if client resolves www.domain.tld to ipaddress 1.2.3.4, and server that has IP address 1.2.3.4 knows what to do with www.domain.tld vs www.domain2.tld that also resolves to 1.2.3.4 then your fine.  This is virtual hosting or host headers.

 

What httpd are you running on what os that this is the correct path for the config?

/etc/httpd/conf/httpd.conf

Share this post


Link to post
Share on other sites

Sorry for late reply @Budman. But, I'm running httpd on CentOS 6.

 

I've been working on this and I can now work with .htaccess. I have also read the link you gave and rewriting. But the problem still persists. I'm unable to redirect to a specified path for a specified HTTP_HOST.

 

So let me make it even simpler

 

I want to redirect for a specific HTTP_HOST to something like http://10.5.5.5:8080/myfolder1/index.html

 

 


RewriteCond %{HTTP_HOST} ^www.home.com$ [NC]
RewriteRule ^$ /test.php [P,L]

 

The above works

 

But anything else that I have tried to put the path explicity as in the rewrite rule doesn't work! The basic idea is to redirect to a different folder without changing the url on the address bar.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.