Find the answer to your Linux question:
Results 1 to 4 of 4
Hi everybody, I've been 4 days trying to do something I thought would be easy, but I'm having a lot of problems. So, what I want to do is FORWARDING ...
  1. #1
    Just Joined!
    Join Date
    Jul 2006
    Posts
    51

    [SOLVED] Apache2 mod_proxy mod_rewrite

    Hi everybody,

    I've been 4 days trying to do something I thought would be easy, but I'm having a lot of problems.

    So, what I want to do is FORWARDING web petitions from 1 webserver to another.

    Well, this is the scenary:

    1 router, and 3 Servers (S1, S2, and S3), and a domain Example Web Page
    S1 - 10.0.0.5, S2 - 10.0.0.6, S3 - 10.0.0.7
    S1 is the Server where Router sends all peticions throught the port 8080
    S3 is the Server where Router sends all peticions throught the port 80


    The objective is that when I write Example Web Page, S1 sends me to S2.

    So, I followed these steps:

    • Enable needed modules:
      Code:
      a2enmod rewrite
      a2enmod proxy
      a2enmod proxy_http
      
      apache restart

    • Edit /etc/apache2/mods-enabled/proxy.conf
      Code:
      <IfModule mod_proxy.c>
              ProxyRequests Off
              <Proxy *>
                     AddDefaultCharset off
                      Order deny,allow
                      Allow from all
              </Proxy>
              ProxyVia On
      </IfModule>

    • Create /etc/apache2/sites-available/example
      Code:
      NameVirtualHost *:8080
      <VirtualHost *:8080>
              <Proxy *>
                      Order deny,allow
                      Allow from all
              </Proxy>
              ServerName              www.example.com
              RewriteEngine on
              ProxyPass               / http://10.0.0.6
              ProxyPassReverse        / http://10.0.0.6
      </VirtualHost>

    • Enable the new site
      Code:
      a2ensite example


    Finally I restarted apache and added 10.0.0.6 Example Web Page to my /etc/hosts file.

    Well, when I tried it, I see the login page of my web application in 10.0.0.6, but when I login, I get this error:
    Code:
    Proxy Error
    
    The proxy server received an invalid response from an upstream server.
    The proxy server could not handle the request POST /login.
    
    Reason: DNS lookup failure for: 10.0.0.6login
    
    Apache/2.2.3 (Debian) Server at egestio.ditecsa.com Port 8080
    Anybody knows whats the problem?

    Thanks a lot friends.

  2. #2
    Linux Engineer jledhead's Avatar
    Join Date
    Oct 2004
    Location
    North Carolina
    Posts
    1,077
    ok, now I am confused

    without proxying, I am assuming the web servers can be accessed in the following way:

    S1 - 10.0.0.5 - can be accessed thru http://10.0.0.5/
    S2 - 10.0.0.6 - can be accessed thru http://10.0.0.6:8080/
    S3 - 10.0.0.7 - can be accessed thru http://10.0.0.7/

    is that correct or do I have it wrong?

  3. #3
    Just Joined!
    Join Date
    Jul 2006
    Posts
    51
    Hi jledhead,

    yes, it is correct.

    To be more clear, the final objective is to have the S1 (10.0.0.5) as a frontal proxy to ditribute the peticions by port 80 to S2 or S3 depending on the domain used by the client.

    So, I have just 1 public IP address. And I have 1 domain and 1 subdomain pointing to this IP address. This is what I want to dintinct.

    Aleix

  4. #4
    Just Joined!
    Join Date
    Jul 2006
    Posts
    51
    Hi jledhead,

    finally someone helpel me to find the error.

    It was really simple, but when you have been so much days fighting with thaht, you can't see the obvious things...

    So, if you read the error with attention:

    Code:
    Proxy Error
    
    The proxy server received an invalid response from an upstream server.
    The proxy server could not handle the request POST /login.
    
    Reason: DNS lookup failure for: 10.0.0.6login
    We will find the problem:
    Code:
    ProxyPass               / http://10.0.0.6
    ProxyPassReverse        / http://10.0.0.6
    The key is that I need another slash at the final, so, it should be:
    Code:
    ProxyPass               / http://10.0.0.6/
    ProxyPassReverse        / http://10.0.0.6/
    Thank you very much!

    Aleix

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •