On 01.03.2012 21:35, kadvar wrote:
Amos Jeffries-2 wrote
#192.168.124.41/images has to be redirected to another web server
acl images urlpath_regex images
Problem #1: everything with the letters "images" in the URL path
gets
matched by this.
For examples:
http://example.com/images/haha.html
http://example.com/boo/?images
http://example.com/scripts/images.js
http://example.com/videos/images.avi
http://google.com/images?q=boo
http://192.168.124.41/images.html
Careful with regex.
#now that images has been found deny the request being sent to
server
1
cache_peer 127.0.0.1 parent 80 0 no-query originserver name=server1
cache_peer_access server1 deny images
PROBLEM #2: "myimage.jpg" does not contain an "s". The 'images' ACL
definition does not prevent it going to this peer.
#now send the image requests to server 2, first create peer
cache_peer 192.168.124.40 parent 80 0 no-query originserver
name=server2
#now send image requests to peer
cache_peer_access server2 allow images
cache_peer_access server2 deny all
Amos
Thank you for that! I still have a problem with the images thing. I
re-wrote
the regex as
acl images_reg urlpath_regex ^/images/
Lets say I have a page www.mysite.com/images/mygallery.html which has
an
image file tiger.jpg embedded. Now squid matches
www.mysite.com/images/mygallery.html and sends it to server 2 but
still
looks for tiger.jpg on server 1 even though it's on the same server
as
mygallery.html (server 2).
Squid does not know in advance which server an object is on, of course.
All it has to go on is the cache_peer_access rules you give it and
whether or not that ACL matches the path. Where a different object
(mygallery.html) came from in the past is irrelevant to tiger.jpg.
The config you shows a post ago had:
server1 accepts all requests *unless* they match the ACL.
server2 accepts *only* requests which match the ACL.
Which puts the problem in the ACL pattern versus the URL your objects
use.
Take a close look at the full URL-path for tiger.jpg and manually
compare it against the pattern you told Squid to match.
NP: I'm not going to tell you where the problem is this time because it
is very obvious you need to learn what you are doing. Best way to learn
is to struggle and solve it yourself.
Amos