Jump to content



Photo

Redirect server traffic locally


  • Please log in to reply
34 replies to this topic

#31 OP mediator

mediator

    Neowinian

  • Tech Issues Solved: 1
  • Joined: 22-January 07

Posted 06 April 2014 - 07:29

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.




#32 +BudMan

BudMan

    Neowinian Senior

  • Tech Issues Solved: 106
  • Joined: 04-July 02
  • Location: Schaumburg, IL
  • OS: Win7, Vista, 2k3, 2k8, XP, Linux, FreeBSD, OSX, etc. etc.

Posted 06 April 2014 - 12:20

Dude this has been answered and have kicked the dead horse a few times already..

 

What part did you not understand about host headers or virtual hosts??

 

http://httpd.apache....ocs/2.2/vhosts/

 

http://technet.micro...5(v=ws.10).aspx



#33 OP mediator

mediator

    Neowinian

  • Tech Issues Solved: 1
  • Joined: 22-January 07

Posted 06 April 2014 - 19:40

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.



#34 +BudMan

BudMan

    Neowinian Senior

  • Tech Issues Solved: 106
  • Joined: 04-July 02
  • Location: Schaumburg, IL
  • OS: Win7, Vista, 2k3, 2k8, XP, Linux, FreeBSD, OSX, etc. etc.

Posted 07 April 2014 - 10:29

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

 

@Sammy - I'm using Tomcat

 

http://tomcat.apache...ting-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



#35 OP mediator

mediator

    Neowinian

  • Tech Issues Solved: 1
  • Joined: 22-January 07

Posted 14 April 2014 - 14:18

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...der1/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.