Re: Rewrite Rule Help (again)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 11, 2012 at 1:22 PM, Chris Arnold <carnold@xxxxxxxxxxxxxxxxxxx> wrote:
>You may need to change the R to a P:

>RewriteEngine On
>RewriteCond %{HTTP_HOST} !^update.domain.com$ [NC]
>RewriteRule ^/$ http://private.ip.address/ [P,L]

This sends all http traffic to the private ip server

>This turns the rule into a proxy to that private IP, assuming that is
>what you are trying to accomplish.

I am not sure what the "technical" name is of what i am trying to do. The lines between rewrite and proxy are blurred to say the least. That is why i have tried to give an accurate description of what i am trying to do.


>Finally, if you want URLS other than the root to be proxied, you may
>need to capture the URI like so:

>RewriteEngine On
>RewriteCond %{HTTP_HOST} !^update.domain.com$ [NC]
>RewriteRule ^/(.*)$ http://private.ip.address/$1 [P,L]

Because the first suggestion did not work, i tried this one and it sends all http traffic to the iis server too.
Just to maybe giv a better account of what i am trying to do. We have a webserver (say webserv A) that fulfills http port 80 requests and uses apache. We have another webserver that runs a program that requires it to run on 80 and uses iis. We have 1 public ip, with public dns entries for a number of hostnames and matching private dns entries. The firewall sends all port 80 traffic to the apache server. We need only updates.domain.com (this will come to the apache server) to be redirected/proxied to the iis server. We need the other websites, domain.com and the other domain.com/folder sites to still be served on the apache server. Here is the first part of the vhost file:
<VirtualHost *:80>
    ServerAdmin email@xxxxxxxxxx
    ServerName domain.net
    ServerAlias www.domain.net

    #SSLProxyEngine On
    #ProxyPass /ifolder/ https://192.168.123.4/ifolder/
    #ProxyPassReverse /ifolder/ https://192.168.123.4/ifolder/
    RewriteEngine On
    RewriteRule ^/ifolder(.*) https://%{HTTP_HOST}/ifolder/ [L]
    RewriteRule ^/admin(.*) https://%{HTTP_HOST}/admin/ [L]
    RewriteCond %{HTTP_HOST} !^updates.domain.net$ [NC]
    RewriteRule ^/(.*)$ http://192.168.123.2/$1 [P,L]


I hoped this clears up some stuff up and makes it clear what i need apache to do.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


Your configuration doesn't make sense. When requests for updates.domain.net come apache will look in the VirtualHost configurations and try to find the one that matches the server name ie ServerName updates.domain.net. In your case virtual host like that doesn't exists. Putting the redirects inside virtual host named domain.net WILL NOT work from the reason I just explained, that virtual host will never receive those requests.

So, you have two options:

1. Create new virtual host with ServerName updates.domain.net
2. Put the redirect lines OUTSIDE the wrong virtual host ie in the httpd.conf file so they get caught by the server when none of the hosts match the request HTTP_HOST

which was exactly what Eric Covener suggested on 4 of July:

Check %{HTTP_HOST} with a rewritecond or put it in a context (non
default name-based vhost) that only matches the desired hostname.

but you didn't understand it obviously.

Cheers,
Igor




[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux