Sub-domain redirect to Virtual machine

Discussion in 'Installation/Configuration' started by sjswarts, Oct 22, 2011.

  1. sjswarts

    sjswarts New Member

    Hi guys, (IP addresses aren't real)

    I HAVE purchased the ISPConfig Manual already - still can't figure it out
    What I need to do is this:

    I have a Debian Server running ISPConfig 3 which works fine with my websites so far. What I want to do is host a sub domain on a virtual machine.

    Currently my setup is
    ISPConfig 3 server : 192.168.1.1/24 server1.example.com
    Virtual Machine: 192.168.1.8/24 server2.example.com

    If i put the ip address into the url with 192.168.1.8/test it shows the website i want, but if i put in www.example.com/test it comes back with a error.

    I have added a sub-domain in ISPConfig
    Host: server2
    Domain: example.com
    Redirect: R,L
    Redirect path: http://server2.example.com/test/

    I have a CNAME entry as
    server2 192.168.1.8

    What am I missing??? This has me stumped... Thanks in advance
     
  2. falko

    falko Super Moderator Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    You want to redirect the subdomain server2.example.com to server2.example.com? I think you have a loop there...
     
  3. sjswarts

    sjswarts New Member

    That could be ... what I need to know is how to achieve my goal.

    I have www.example.com going to my normal website on server1.example.com which has for its IP 192.168.1.1/24 - this is working already.

    Now I also want when people access a link or directly enter into the URL www.example.com/example that it redirects to my second server which has a hostname server2.example.com ip 192.168.1.8/24 and is also running apache

    I am wondering how do I do this in ISPConfig 3 or is there a better way to achieve the same goal?

    Thanks for your response

    Steve
     
  4. falko

    falko Super Moderator Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    Go to the Redirect tab of your website in ISPConfig and configure your redirect there.
     
  5. sjswarts

    sjswarts New Member

    That would work if I had the server else where but I don't.

    They are physically at the same address on the same internet connection coming from the same ADSL router - obviously I can't forward port 80 to both only one

    This is the connection:

    ADSL Router (1) ==port forward 80==> Debian Server1 hosts www.example.com

    ADSL Router (1) ==NO PORT FORWARD===> Debian Server2 hosts www.example.com/example

    Server1 192.168.1.1/24
    Server2 192.168.1.8/24

    How do I get Server1 to redirect a URL request asking for www.example.com/example to server2 on the same network?

    Thanks steve
     
  6. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    You can do this e.g. by configuring a reverse proxy with apache mod_proxy.
     
  7. sjswarts

    sjswarts New Member

    Thats what I have found out so far from google but I'm wondering how I can do that with ISPConfig installed... Where do i put it and what do I put in...

    If you could please direct me to a good site that would be fantastic

    Cheers,
    Steve
     
  8. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    I dont have a link to a site at hand. But in general, it should be enough to add the directives for the reverse proxy in the apache directives field of the website in ispconfig.

    Before you do that, make sure that the apache reverse proxy modules are installed and loaded on your server.
     
  9. sjswarts

    sjswarts New Member

    Ok Till thank you for your comment seems like i'm in the right direction...

    this is a extract from my vhost file on the website that I want to run apache reverse proxy...
    ======================================================
    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy 192.168.1.1:80>
    Order deny,allow
    Allow from all
    </Proxy>

    ProxyPass /example http://server2.example.com/
    ProxyPassReverse /example http://server2.example.com/
    ======================================================
    i have also added a CNAME in dns:

    server2.example.com.
    192.168.1.8

    It comes up with a error not found which is different than before so I am on the right track "hope"

    What am I doing wrong?

    Thanks
    steve
     
  10. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    The question is if there is a problem with the proxy or the target page. Lets first test the target page:

    Do you get the correct page when you open the URL http://server2.example.com/ inside your local network in a browser?
     
  11. sjswarts

    sjswarts New Member

    Yes I have tried that and with the DNS set to 192.168.1.1 it responds correctly... Now I just have to get it to redirect to that.
     
  12. sjswarts

    sjswarts New Member

    Ok so I have figured it out thanks to Till (sent me in the right direction)

    This is how to do it if you meet the criteria of having Debian and ISPConfig installed on your nominated recipient of the port 80 request. Other flavors no doubt will work as well just might need some editing. Also make sure you have a A record set up for the secondary apache web server.

    Port 80 for me was sent to server1.example.com which had a ip of 192.168.1.1/24

    So I edited example.com.vhost in /etc/apache2/sites-available/example.com.vhost

    Scroll down to after it talks about the directory locations and settings (probably doesn't need to be here but that is where i put it) and place this (obviously editing it to suit your needs)

    ========================================================

    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy 10.1.5.15:80>
    Order deny,allow
    Allow from all
    </Proxy>

    ProxyPass /example http://server2.example.com/example
    ProxyPassReverse /example http://server2.example.com/example

    =========================================================

    What I forgot to add was the example after the forward slash. After restarting apache with a /etc/init.d/apache2 restart everything went where I wanted it.

    Hopefully this helps someone else. Thanks to all and if it doesn't work out I will come back here...

    Regards,
    Steve
     
    Last edited: Oct 24, 2011

Share This Page