Forum Moderators: phranque

Message Too Old, No Replies

change proxy url

         

Rodjaaa

1:49 am on Mar 27, 2014 (gmt 0)

10+ Year Member





I have problem with proxy requests. I need to enable apache mod_proxy for my subdomains but i forgot to set Allow from example.com, it was Allow from all...Yes, i created open proxy for all world... So, now when i set Deny from all, Allow from example.com i am getting errors that some clients have been rejected because of server conf which is good, and in access.log i have get request for some urls with return code 403 which is also good. This is one of requests.

e.g. "GET http://www.google.com HTTP/1.1 403 462"-"Mozilla/4.0 (compatible; MSIE 6.0;)"


My question is can i modify urls that is comming to me to some another url?

Can i change this url "google.com" to "example.com"?

lucy24

7:27 am on Mar 27, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Why would you want to?

Ordinarily this kind of thing is covered with the basic domain-name-canonicalization redirect. It's obviously a little more complicated when you have subdomains. But if it's the same overall domain, you can still say something like

:: off the top of my head ::

RewriteCond %{HTTP_HOST} !example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


You've probably got something of the sort already, only this version comes without anchors. The idea is to intercept any and all requests that don't ask for your domain, and say It's My Way Or The Highway. Or words to that effect. But a 403 is also a perfectly legitimate response.

Rodjaaa

7:54 am on Mar 27, 2014 (gmt 0)

10+ Year Member



Do i need ^ and $ in condition? !^example\.com$. This isnt working...

lucy24

9:06 am on Mar 27, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



No, absolutely not. The point is to shut out any request that doesn't mention example.com at all. This is separate and distinct from the canonicalization redirect, where you'd list the exact preferred form of each (sub)domain name. There you do have to use anchors.

some clients have been rejected because of server conf

Are you referring to the standard line in error logs that says "Client denied by server configuration"? Well, I'm glad someone likes the line. I've always found it maddeningly unhelpful.

phranque

9:33 am on Mar 27, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, Rodjaaa!


you can redirect a request to another url by providing a 301 or 302 status code and a Location: HTTP Response header instead of the 403 status code.

there are various techniques available for this including the apache mod_rewrite module.

Rodjaaa

10:29 am on Mar 27, 2014 (gmt 0)

10+ Year Member



thanks, phranque!

Ok, now i'm getting 302 error. In my httpd.conf i added line
ErrorDocument 403 http://example.com
but now i'm getting 302 error because of endless loop. How can i allow in proxy conf to allow only this (http://example.com) get request?

phranque

11:22 am on Mar 27, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



http://httpd.apache.org/docs/current/mod/core.html#errordocument
Note that when you specify an ErrorDocument that points to a remote URL (ie. anything with a method such as http in front of it), Apache HTTP Server will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that the client will not receive the original error status code, but instead will receive a redirect status code. This in turn can confuse web robots and other clients which try to determine if a URL is valid using the status code.

Rodjaaa

11:54 am on Mar 27, 2014 (gmt 0)

10+ Year Member



I did it!

I add SetEnvIF Host example/.com AllowIP and Allow from env=AllowIp. Now proxy throws error 403 and after that allow http://example.com with code 200.

lucy24

6:29 pm on Mar 27, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ok, now i'm getting 302 error.

A 302 isn't an error; it's simply the "temporary redirect" status code. It's the default code when a target gives a full hostname.