Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am building a squid reverse proxy. to balance between 2 servers with different files. Server 1 contains 500 folders ranging from 000 - 499. Server 2 had 500 folders ranging from 500 - 999.

I'm struggling with the Regular expression to say from folder 500 - 999.

My config file is as follows for squid 3.1 which currently goes to folder 000 to 499 without issues and only folder 500, 501, and 502 on the second box. Would like to use a regular expression for 500 - 999

http_port 80 accel defaultsite=image.test.co.za

acl foo urlpath_regex ^"/500 /501 /502


cache_peer 172.16.0.8 parent 80 0 no-query originserver name=server1
cache_peer_access server1 deny foo

cache_peer 172.16.0.9 parent 80 0 no-query originserver name=server2
cache_peer_access server2 allow foo
cache_peer_access server2 deny all

RESOLVED BY LAIN

The correct config file for future reference is:

http_port 80 accel defaultsite=image.test.co.za
acl foo urlpath_regex [5-9][0-9][0-9]

cache_peer 172.16.0.8 parent 80 0 no-query originserver name=server1
cache_peer_access server1 deny foo

cache_peer 172.16.0.9 parent 80 0 no-query originserver name=server2
cache_peer_access server2 allow foo
cache_peer_access server2 deny all
share|improve this question
1  
Actually you probably really want something like '/[5-9][0-9][0-9]/' or even '^/[5-9][0-9][0-9]/' or similar depending on your URL structure. –  Iain Jun 14 '12 at 7:37

1 Answer 1

up vote 0 down vote accepted

I don't have a suitably configured squid to check bit a regex that will match 500-999 would be

[5-9][0-9][0-9]

Note that this will also match any string that begins with a number >= than 500 so they would be passed to server2 as well.

share|improve this answer
    
Brilliant, thank you. It worked like a charm. Attached is the working config file for future reference. –  shaun Jun 14 '12 at 7:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.