프로그램 사용/squid2019. 2. 27. 20:36

퇴근길에 검색하다가 우연히 발견한 문서

squid에서 HIER/NONE 이라고 뜨는 녀석은 캐싱이 안되는데

기본값으로 원래 서버로 요청을 돌려주도록 되어 있다고 한다.


parent가 누굴 지칭하는지 모르겠지만 global hit rate에는 영향을 못 미치면서 latency만 늘어난다라...


#  TAG: nonhierarchical_direct

# By default, Squid will send any non-hierarchical requests

# (matching hierarchy_stoplist or not cachable request type) direct

# to origin servers.

#

# If you set this to off, then Squid will prefer to send these

# requests to parents.

#

# Note that in most configurations, by turning this off you will only

# add latency to these request without any improvement in global hit

# ratio.

#

# If you are inside an firewall then see never_direct instead of

# this directive.

#

#Default:

# nonhierarchical_direct on 

[링크 : http://www.squid-cache.org/mail-archive/squid-users/200203/att-0514/squid.conf]


+

캐시 hierarchy 라는게 있어서 찾아보기..

[링크 : https://wiki.squid-cache.org/Features/CacheHierarchy]


+

헐?

[링크 : http://www.squid-cache.org/Doc/config/offline_mode/]

[링크 : https://stackoverflow.com/.../how-can-squid-be-configured-to-cache-all-downloaded-files]

'프로그램 사용 > squid' 카테고리의 다른 글

squid url_rewrite_program  (0) 2019.03.14
squid log code  (0) 2019.03.01
squid용 인증서 관련 (인증서 변환하기)  (0) 2019.02.25
HSTS-HTTP Strict Transport Security / squid  (0) 2019.02.25
squid as transparent proxy  (0) 2019.02.19
Posted by 구차니
프로그램 사용/squid2019. 2. 25. 12:25

생각해보니 뻘짓 한 듯..

그나마 도움이 된건 각종 인증서를 변환하는 방법을 찾은 것?

[링크 : https://www.digitalocean.com/community/tutorials/how-to-create-an-ssl-certificate-on-apache-for-centos-7]

[링크 : https://www.securesign.kr/guides/SSL-Certificate-Convert-Format]




pem to crt

해보니까 이전에 생성하던 der 이랑 동일한 내용

$ openssl x509 -outform der -in your-cert.pem -out your-cert.crt

[링크 : https://stackoverflow.com/questions/13732826/convert-pem-to-crt-and-key]


pem to key

$ openssl rsa -outform der -in private.pem -out private.key

[링크 : https://stackoverflow.com/questions/19979171/how-to-convert-pem-into-key]


[링크 : https://www.lesstif.com/pages/viewpage.action?pageId=6979614]

[링크 : https://www.lesstif.com/pages/viewpage.action?pageId=19365977]

Posted by 구차니
프로그램 사용/squid2019. 2. 25. 09:37

+

2019.02.28

HSTS는 HTTP Strict Transport Security 약자로

간단하게 요약하면 HTTP로 접속하면 강제로 HTTPS로 전환하는 그런류의 기술 인 듯?


+

2019.02.28

youtube 캐시하는걸 해보려는데 HSTS 오류 어쩌구 떠서(크롬에서) 찾아보는데

역시 뻘짓 한 듯... HTTP -> HTTPS 하면서 보안 강화한 상황이라

그 이전의 유튜브 캐싱에 대한 내용들로 열심히 삽질하는 듯..


[링크 : https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security]

[링크 : https://blog.geun.kr/158]

[링크 : https://blog.lael.be/post/6670]

[링크 : chrome://net-internals/#hsts]


[링크 : https://www.thesslstore.com/blog/clear-hsts-settings-chrome-firefox/]

[링크 : https://support.opendns.com/...-Chrome-for-Windows-only-HSTS-Certificate-Exception-Instructions]

[링크 : https://rsec.kr/?p=315]

[링크 : https://blog.lael.be/post/6670]

Posted by 구차니
프로그램 사용/squid2019. 2. 19. 23:56

프록시 설정하려면 귀찮은데

그걸 해소하기 위한 방법으로 게이트웨이 아이피에다가 proxy 까는 것 처럼

클라이언트 측의 설정 없이 프록시 하는 법을 찾는 중


[링크 : https://www.cyberciti.biz/tips/linux-setup-transparent-proxy-squid-howto.html]

[링크 : https://linuxtechlab.com/squid-transparent-proxy-server-complete-configuration/]


+

방화벽에서 걸러서 프록시로 던져주는 것이 컨셉인듯

[링크 : https://blog.naver.com/kazami20/56490157]


이제 웹브라우저의 도구 -> 인터넷 옵션 -> 연결 -> 랜설정 -> 사용자랜에 프록시 사용을 체크한뒤

자신의 리눅스 프락시로 ip주소를 적고 포트를 3128로 지정해주고 인터넷을 하면

이제부터 보이는 웹 사이트 화면은 먼저 프락시에서 페이지를 읽어온뒤에 윈도우 웹브라우저로

보여지는것이다.

이와 같은 브라우저에서의 프락시 설정을 하지 않고 사용하고 싶을때 패킷필터 방화벽설정을

하여서 80포트로 가는 패킷을 3128번 포트로 리다이렉트하는 방법이 있다.

이것을 Transparent Proxy(투명 프락시)라고 하는데 이것을 설정하는 것은 쉬우며

젤 아래에 설정을 추가할 부분을 추가한다.


------------ Proxy mode 로 사용시 설정 끝 -----------------------------


squid데몬 스타트

/etc/rc.d/init.d/squid start



--------------------- 투명 프락시 사용할시 ---------------------------


투명 프락시를 사용할 경우에는 내부 네트워크(192.168.0.0)가 필요하고

공인 아피를 가진 리눅스가 한대 있다고 가정하고 이 리눅스에는 랜카드가 두개 있어야한다.

즉 리눅스 gateway서버로 돌아가는 리눅스가 한대 필요하다. gateway설정은 kldp를 참조하라.

gateway설정은 잘 되어있다고 보고

아래와 같은 설정을 게이트웨이의 iptables룰에 추가한다.


혹시 모르므로 아래같은 마스크레이드 룰이 적용 안되었다면 적용해라


iptables -t nat -A POSTROUTING -p TCP -s 0/0 --dport 21 -j MASQUERADE

iptables -t nat -A POSTROUTING -p TCP -d 0/0 --dport 20 -j MASQUERADE

iptables -t nat -A POSTROUTING -p TCP --dport 25 -j MASQUERADE

iptables -t nat -A POSTROUTING -p TCP --dport 110 -j MASQUERADE

iptables -t nat -A POSTROUTING -p TCP --dport 22 -j MASQUERADE

iptables -t nat -A POSTROUTING -p TCP --dport 23 -j MASQUERADE


echo "###################################################################################"

echo "###                Transparent Proxy with Squid                  ###"

echo "### iptables -t nat -A PREROUTING -p TCP --dport 80 -j REDIRECT --to-port 3128  ###"

echo "###################################################################################"



그리고 squid.conf에 다음의 설정을 추가한다.


httpd_accel_host virtual

httpd_accel_port 80

httpd_accel_with_proxy on

httpd_accel_uses_host_header on 

[링크 : http://coffeenix.net/board_view.php?cata_code=0&bd_code=129&bpage=]

Posted by 구차니
프로그램 사용/squid2019. 2. 18. 17:44

묘하게 비문인가. 오타인가 이해가 안되고 번역도 잘 안되고...


min / percent / max는 명시적 만료시간(explicit expiry time)이 정의되지 않은 애들에 대한 설정으로  

패킷캡쳐를 해보니 HTTP 내부에 이런 식으로 응답이 오는 걸 확인하였는데

요기에 expires나 Cache-Control : max-age 등에 값이 없을 경우에 대한 녀석으로 생각된다.

[링크 : https://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html]


usage: refresh_pattern [-i] regex min percent max [options]


By default, regular expressions are CASE-SENSITIVE.  To make

them case-insensitive, use the -i option.

>>>>>

기본적으로 정규표현식은 대소문자를 구분합니다. 대소문자를 구분하지 않으려면 -i 옵션을 사용하시기 바랍니다.


'Min' is the time (in minutes) an object without an explicit

expiry time should be considered fresh. The recommended

value is 0, any higher values may cause dynamic applications

to be erroneously cached unless the application designer

has taken the appropriate actions.

>>>>>

'Min' 명시적 만료시간이 존재하지 않는 객체에 대해 신선하다고 간주되어야 할 시간 (분단위) 입니다.

추천되는 값은 0으로, 그 이상의 값은 어플리케이션 디자이너가 적절한 행동을 취해야하지 않는다면

다이나믹 어플리케이션에서 오류가 있는 캐시를 야기할 수 있습니다.

(다이나믹 웹에서 갱신되지 않는 옛 데이터를 캐시할 수 있다?)


'Percent' is a percentage of the objects age (time since last

modification age) an object without explicit expiry time

will be considered fresh.

>>>>>

'Percent'는 명시적 만료시간이 존재하지 않는 객체에 대해 신선하다고 간주되어야 할 나이(마지막 수정일로 부터의 나이)의 비율입니다.

(나중에 나올 LM Factor 인가?)


'Max' is an upper limit on how long objects without an explicit

expiry time will be considered fresh. The value is also used

to form Cache-Control: max-age header for a request sent from

Squid to origin/parent.

>>>>>

'Max' 명시적 만료시간이 존재하지 않는 객체에 대해 신선하다고 간주되어야 할 상한선 입니다.

이 값은  Squid로 부터 origin/parent로 요청되는 양식 Cache-Control: max-age 헤더로부터 사용됩니다.


options: override-expire

override-lastmod

reload-into-ims

ignore-reload

ignore-no-store

ignore-private

max-stale=NN

refresh-ims

store-stale


override-expire enforces min age even if the server

sent an explicit expiry time (e.g., with the

Expires: header or Cache-Control: max-age). Doing this

VIOLATES the HTTP standard.  Enabling this feature

could make you liable for problems which it causes.

>>>>>

override-expire 는 서버가 명시적 만료시간을 보내더라도 min age를 강제합니다.(예 Expires: header 혹은 Cache-Control: max-age).

이것은 HTTP 표준을 위반합니다. 이 기능을 활성화 시키면 그것으로부터 야기되는 문제들에 대해 책임을 져야합니다.


Note: override-expire does not enforce staleness - it only extends

freshness / min. If the server returns a Expires time which

is longer than your max time, Squid will still consider

the object fresh for that period of time.

>>>>>

알림 : override-expire는 부패를 강제 하지 않습니다 - 단지 신선함에 대한 min 시간을 늘립니다.

당신의 최고 시간보다 긴 만료시간을 서버가 보낸다면, Squid는 그 기간 동안은 신선함으로 판단할 것입니다.


override-lastmod enforces min age even on objects

that were modified recently.

>>>>>

override-lastmod는 최근 수정되었다 하더라도 객체에서 min 값을 강제합니다.


reload-into-ims changes a client no-cache or ``reload''

request for a cached entry into a conditional request using

If-Modified-Since and/or If-None-Match headers, provided the

cached entry has a Last-Modified and/or a strong ETag header.

Doing this VIOLATES the HTTP standard. Enabling this feature

could make you liable for problems which it causes.

>>>>>

reload-into-ims는 클라이언트의 Cache-Control : no-cache나 

캐시된 항목을 위해 요청되는 

캐쉬된 항목이 지니는 Last-Modified 와/나 강력한 ETag 헤더에 의해 제공되는

IMS(If-Modified-Since) 와/나 INM(If-None-Match) 헤더들로 부터의

조건부 요청에 의한 reload 요청을 변화합니다.


ignore-reload ignores a client no-cache or ``reload''

header. Doing this VIOLATES the HTTP standard. Enabling

this feature could make you liable for problems which

it causes.

>>>>>

ignore-reload는 클라이언트의 no-cache나 reload 헤더를 무시합니다.

이것은 HTTP 표준을 위반합니다. 이 기능을 활성화 시키면 그것으로부터 야기되는 문제들에 대해 책임을 져야합니다.


ignore-no-store ignores any ``Cache-control: no-store''

headers received from a server. Doing this VIOLATES

the HTTP standard. Enabling this feature could make you

liable for problems which it causes.

>>>>>

ignore-no-store는 서버로 부터 받아지는 어떠한 'Cache-control: no-store' 헤더도 무시하도록 합니다.

이것은 HTTP 표준을 위반합니다. 이 기능을 활성화 시키면 그것으로부터 야기되는 문제들에 대해 책임을 져야합니다.


ignore-private ignores any ``Cache-control: private''

headers received from a server. Doing this VIOLATES

the HTTP standard. Enabling this feature could make you

liable for problems which it causes.

>>>>>

ignore-private는 서버로 부터 받아지는 어떠한 'Cache-control: private' 헤더도 무시하도록 합니다.

이것은 HTTP 표준을 위반합니다. 이 기능을 활성화 시키면 그것으로부터 야기되는 문제들에 대해 책임을 져야합니다.


refresh-ims causes squid to contact the origin server

when a client issues an If-Modified-Since request. This

ensures that the client will receive an updated version

if one is available.

>>>>>

refresh-ims는 클라이언트가 IMS(If-Modified-Since) 요청을 발행하였을때 원본 서버로 부터 squid의 접속을 발생하도록 합니다.

이것은 클라이언트가 가능하다면 업데이트 된 버전을 받도록 보장합니다.


store-stale stores responses even if they don't have explicit 

freshness or a validator (i.e., Last-Modified or an ETag) 

present, or if they're already stale. By default, Squid will 

not cache such responses because they usually can't be

reused. Note that such responses will be stale by default.

>>>>>

store-stale 는 명시적인 신선함이나 감별자 (예로 Last-Modified 혹은 ETag)존재가 없거나 혹은 그것들이 이미 신선하지 않더라도 응답을 저장합니다.

그것들이 대부분 재사용될 수 없기 때문에, 기본적으로 Squid는 이러한 응답들을 캐시하지 않을 것입니다.


max-stale=NN provide a maximum staleness factor. Squid won't

serve objects more stale than this even if it failed to

validate the object. Default: use the max_stale global limit.

>>>>>

max-stale=NN은 최대 부패 요소를 제공합니다. Squid는 객체를 입증하는데 실패하더라도, 이 값 보다 더 부패한 객체에 대해서 제공하지 않을 것입니다. 

기본값 : max_stale 전역 제한을 사용합니다.


결론 : 번역해서 먼소리인지 모르겠다!!!!


+

HTTP 프로토콜을 들여다 보게 될 줄이야 ㅠㅠ

전부 Cache-Control 하위 설정들이었구나..

캐시 요청 디렉티브

Cache-Control: max-age=<seconds>

Cache-Control: max-stale[=<seconds>]

Cache-Control: min-fresh=<seconds>

Cache-control: no-cache 

Cache-control: no-store

Cache-control: no-transform

Cache-control: only-if-cached 

[링크 : https://developer.mozilla.org/ko/docs/Web/HTTP/Headers/Cache-Control]

'프로그램 사용 > squid' 카테고리의 다른 글

HSTS-HTTP Strict Transport Security / squid  (0) 2019.02.25
squid as transparent proxy  (0) 2019.02.19
squid LM-factor? (Last Modified)  (0) 2019.02.18
squid access log 종류..  (2) 2019.02.17
mrtf centos  (0) 2019.02.14
Posted by 구차니
프로그램 사용/squid2019. 2. 18. 10:56

이건 또 언제보냐..

일단 뒤에 squid 번역해 보고 나니 조금 이해 되는 듯 한데

이해한 걸 적자면.. ILM(If-Last-Modified) 으로 설정되었을 경우

(현재 시간 - LastModified 시간) * Percent(Squid에서 설정되는 그 값)가 Fresh 하다고 간주되는 시간이다.

근데... 현재 시간이 그럼 늦게 접속하면.. 오랜시간 동안 변하지 않았으니

Fresh로 오랫동안 간주해도 된다는 의미인가?

2019/02/18 - [프로그램 사용/squid] - 끄으으응.. squid 번역을 한번 했어야 했나.. refresh_pattern


The response is stale if the response age is greater than the refresh_pattern max value.

refresh_pattern max 값 보다 응답 시간이 클 경우 응답은 부패한 것 으로 간주합니다.


The response is fresh if the LM-factor is less than the refresh_pattern percent value.

refresh_pattern percent 값 보다 LM-factor가 적을 경우 응답은 신선한 것 으로 간주합니다.


The response is fresh if the response age is less than the refresh_pattern min value.

refresh_pattern min 값 보다 응답 시간이 적을 경우 응답은 신선한 것 으로 간주합니다.


Otherwise, the response is stale.

그 외에는 응답은 부패한 것으로 간주합니다. 


override-expire

When set, this option causes Squid to check the min value before checking the Expires header. Thus, a non-zero min time makes Squid return an unvalidated cache hit even if the response is preexpired.

이 옵션은 Squid가 Expire 헤더를 확인하기 전에 min 값을 확인하도록 설정합니다. 그러므로 0이 아닌 min 값은 Squid가 응답이 만료되기 전이라도 캐시 적중을 무효화 하게 됩니다.


override-lastmod

When set, this option causes Squid to check the min value before the LM-factor percentage.

이 옵션은 Squid가 LM-factor 퍼센트 보다 먼저 min 값을 확인하도록 설정합니다.


reload-into-ims

When set, this option makes Squid transform a request with a no-cache directive into a validation (If-Modified-Since) request. In other words, Squid adds an If-Modified-Since header to the request before forwarding it on. Note that this only works for objects that have a Last-Modified timestamp. The outbound request retains the no-cache directive, so that it reaches the origin server.

이 옵션은 Squid가 no-cache 지시어가 있는 요청을 유효한 (IMS If-Modified-Since)요청으로 변환하도록 설정합니다. 다르게 말하자면, Squid는 IMS(If-Modified-Since) 헤더를 덧붙여서 전달합니다. 이 설정은 Last-Modified 타임스탬프가 존재하는 객체에 대해서만 작동합니다. 

아웃바운드 요청은 no-cache 지시어를 유지하며, 원본 서버에 도달하게 됩니다.


ignore-reload

When set, this option causes Squid to ignore the no-cache directive, if any, in the request.

이 옵션은 Squid가 no-cache 지시어를 무시하도록 설정합니다. 

[링크 : http://etutorials.org/.../Chapter+7.+Disk+Cache+Basics/7.7+refresh_pattern/]

'프로그램 사용 > squid' 카테고리의 다른 글

squid as transparent proxy  (0) 2019.02.19
끄으으응.. squid 번역을 한번 했어야 했나.. refresh_pattern  (0) 2019.02.18
squid access log 종류..  (2) 2019.02.17
mrtf centos  (0) 2019.02.14
squid cache hit rate 올리기  (0) 2019.02.14
Posted by 구차니
프로그램 사용/squid2019. 2. 17. 20:32

일단 쓰면서 보면 제일 눈에 많이 띄는건 아래의 녀석들인데..


TCP_MISS

TCP_INM_HIT

TCP_MEM_HIT

TAG_NONE


HIER_DIRECT

HIER_NONE


HIT는 HIT인데 나머지는 감이 안온다.. ㅠㅠ

찾아도 왜이렇게 안보일까...?

'프로그램 사용 > squid' 카테고리의 다른 글

끄으으응.. squid 번역을 한번 했어야 했나.. refresh_pattern  (0) 2019.02.18
squid LM-factor? (Last Modified)  (0) 2019.02.18
mrtf centos  (0) 2019.02.14
squid cache hit rate 올리기  (0) 2019.02.14
squid 비디오 차단  (0) 2019.02.13
Posted by 구차니
프로그램 사용/squid2019. 2. 14. 13:40

'프로그램 사용 > squid' 카테고리의 다른 글

squid LM-factor? (Last Modified)  (0) 2019.02.18
squid access log 종류..  (2) 2019.02.17
squid cache hit rate 올리기  (0) 2019.02.14
squid 비디오 차단  (0) 2019.02.13
squid 윈도우 업데이트 캐싱  (0) 2019.02.13
Posted by 구차니
프로그램 사용/squid2019. 2. 14. 13:36

정규표현식 문제인지 영 캐시가 잘 안되는 것 같아서

캐시율이 높아야 10% 정도 나오는것 같아서 좀 더 높이는 법을 찾는 중..


[링크 : http://squid-web-proxy-cache.1019090.n4....optimising-caching-or-increasing-hit-ratio-td4681591.html]

[링크 : http://muliantophang.blogspot.com/2013/09/optimize-squid-caching-hit-rate.html]

[링크 : https://aacable.wordpress.com/tag/squid-maximum-cache-hit/]

'프로그램 사용 > squid' 카테고리의 다른 글

squid access log 종류..  (2) 2019.02.17
mrtf centos  (0) 2019.02.14
squid 비디오 차단  (0) 2019.02.13
squid 윈도우 업데이트 캐싱  (0) 2019.02.13
squid cache 정책  (0) 2019.02.13
Posted by 구차니
프로그램 사용/squid2019. 2. 13. 16:30

'프로그램 사용 > squid' 카테고리의 다른 글

mrtf centos  (0) 2019.02.14
squid cache hit rate 올리기  (0) 2019.02.14
squid 윈도우 업데이트 캐싱  (0) 2019.02.13
squid cache 정책  (0) 2019.02.13
squid log format  (0) 2019.02.13
Posted by 구차니