Squid'i HTTPS ileri proxy'si olarak yapılandırılsın mı?


9

İşte benim sorunum hakkında bazı bilgiler:

  • Heroku üzerinde dinamik bir IP adresiyle çalışan bir web hizmetim var. Heroku'daki statik IP'ler bir seçenek değildir.
  • Güvenlik duvarının arkasındaki harici bir web hizmetine bağlanmam gerekiyor. Harici web hizmetini çalıştıran kişiler güvenlik duvarlarını yalnızca belirli bir statik IP'ye açar.

Benim denedim çözüm Squid statik bir IP ile ayrı bir sunucuda Heroku gelen dış hizmet iletmek için kullanmaktır. Bu şekilde harici hizmet, Heroku hizmetinin dinamik IP'si yerine her zaman proxy sunucusunun statik IP'sini görür.

Proxy sunucum kimlik doğrulaması için bir IP adresine güvenemediğinden (bununla başlamak sorun!), Bir kullanıcı adı ve parolaya güvenmelidir. Ayrıca, kullanıcı adı ve parola açık metin olarak iletilemez, çünkü bir saldırgan bu açık metni kesecek olsaydı, o zaman benim gibi davranarak proxy'ime bağlanabilir, proxy'imin statik IP'sini kullanarak giden istekler yapabilir ve böylece harici web servisinin güvenlik duvarı.

Bu nedenle, Squid proxy HTTP değil yalnızca HTTPS üzerinden bağlantı kabul etmelidir. (Harici web hizmetine bağlantı HTTP veya HTTPS olabilir.)

CentOS 6.5.x üzerinde Squid 3.1.10 kullanıyorum ve işte squid.confşimdiye kadar. Yalnızca sorun giderme amacıyla, hem HTTP hem de HTTPS proxy'sini geçici olarak etkinleştirdim, ancak yalnızca HTTPS kullanmak istiyorum.

#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80      # http
acl Safe_ports port 21      # ftp
acl Safe_ports port 443     # https
acl Safe_ports port 70      # gopher
acl Safe_ports port 210     # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280     # http-mgmt
acl Safe_ports port 488     # gss-http
acl Safe_ports port 591     # filemaker
acl Safe_ports port 777     # multiling http
acl CONNECT method CONNECT

# Authorization

auth_param digest program /usr/lib64/squid/digest_pw_auth -c /etc/squid/squid_passwd
auth_param digest children 20 startup=0 idle=1
auth_param digest realm squid
auth_param digest nonce_garbage_interval 5 minutes
auth_param digest nonce_max_duration 30 minutes
auth_param digest nonce_max_count 50

acl authenticated proxy_auth REQUIRED

#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
#http_access allow localnet
#http_access allow localhost
http_access allow authenticated

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 3128

https_port 3129 cert=/etc/squid/ssl/cert.pem key=/etc/squid/ssl/key.pem

# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?

# Disable all caching
cache deny all

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern ^gopher:    1440    0%  1440
refresh_pattern -i (/cgi-bin/|\?) 0 0%  0
refresh_pattern .       0   20% 4320

Bu kurulumu kullanarak HTTP proxy uygulaması sorunsuz çalışır, ancak HTTPS proxy uygulaması çalışmaz.

Yerel bir kutudan bir HTTP proxy isteği şöyledir:

$ curl --proxy http://my-proxy-server.example:3128 \
  --proxy-anyauth --proxy-user redacted:redacted -w '\n' \
  http://urlecho.appspot.com/echo?body=OK
OK

Güzel, beklediğim bu. Bu, bir satırla sonuçlanır /var/log/squid/access.log:

1390250715.137     41 my.IP.address.redacted TCP_MISS/200 383 GET http://urlecho.appspot.com/echo? redacted DIRECT/74.125.142.141 text/html

İşte HTTPS ile bu sefer başka bir istek daha:

$ curl --proxy https://my-proxy-server.example:3129 \
  --proxy-anyauth --proxy-user redacted:redacted -w '\n' \
  http://urlecho.appspot.com/echo?body=OK

curl: (56) Recv failure: Connection reset by peer

Bundan access.logsonra hiçbir şey yok , ama cache.log:

2014/01/20 20:46:15| clientNegotiateSSL: Error negotiating SSL connection on FD 10: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request (1/-1)

İşte yine yukarıdaki, daha ayrıntılı:

$ curl -v --proxy https://my-proxy-server.example:3129 \
  --proxy-anyauth --proxy-user redacted:redacted -w '\n' \
  http://urlecho.appspot.com/echo?body=OK
* Adding handle: conn: 0x7f9a30804000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f9a30804000) send_pipe: 1, recv_pipe: 0
* About to connect() to proxy my-proxy-server.example port 3129 (#0)
*   Trying proxy.server.IP.redacted...
* Connected to my-proxy-server.example (proxy.server.IP.redacted) port 3129 (#0)
> GET http://urlecho.appspot.com/echo?body=OK HTTP/1.1
> User-Agent: curl/7.30.0
> Host: urlecho.appspot.com
> Accept: */*
> Proxy-Connection: Keep-Alive
> 
* Recv failure: Connection reset by peer
* Closing connection 0

curl: (56) Recv failure: Connection reset by peer

SSL hatası gibi görünüyor. Ancak, yukarıdaki yapılandırmada gösterilen cert.pemve key.pemdiğer web sunucularına başarıyla dağıttığım bir alt alan-joker karakterli SSL sertifikasını yeniden kullanıyorum . Ayrıca, proxy sunucusuna doğrudan kıvrılma ile erişmek veya en azından SSL aşamasını geçen bir bağlantı kurmak:

$ curl https://my-proxy-server.example:3129
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ERROR: The requested URL could not be retrieved</title>

[--SNIP--]

<div id="content">
<p>The following error was encountered while trying to retrieve the URL: <a href="https://serverfault.com/">/</a></p>

<blockquote id="error">
<p><b>Invalid URL</b></p>
</blockquote>

<p>Some aspect of the requested URL is incorrect.</p>

<p>Some possible problems are:</p>
<ul>
<li><p>Missing or incorrect access protocol (should be <q>http://</q> or similar)</p></li>
<li><p>Missing hostname</p></li>
<li><p>Illegal double-escape in the URL-Path</p></li>
<li><p>Illegal character in hostname; underscores are not allowed.</p></li>
</ul>

[--SNIP--]

Yanlış yaptığım hakkında bir fikrin var mı? Denediğim şey mümkün mü? Şimdiden teşekkürler.


2
Squid'in böyle çalıştığını sanmıyorum. Bir HTTPS bağlantısı üzerinden proxy veya bir HTTP veya HTTPS isteği yapabilmeliyim. Belgelerde aksini önerecek hiçbir şey göremiyorum. Ne olursa olsun, yine de önerdiğinizi denedim ve işe yaramadı (yukarıdaki ile aynı sonuç).
David

Önceki yorumum, silinen görünen başka bir kullanıcının yorumlarına yanıt olarak yapıldı. Sadece bu soruyu Squid posta listesine çapraz gönderdiğimi not etmek istedim: mail-archive.com/squid-users@squid-cache.org/msg93592.html
David

Benzer bir senaryoya sahip biri olarak, proxy yaklaşımını denedik, başarılı olduk ve uygulamayı Heroku'dan statik bir IP'ye sahip Sanal / Özel makine gibi bir sağlayıcıya taşımayı tercih ettik. Sadece bu amaçla bir ileri proxy sunucusunun bakımının fazladan bir yükü vardır.
Shyam Sundar CS

Yanıtlar:


1

@David, Squid ML'deki iş parçacığına göre - Stunnel çözümü ile devam etmenizi öneririm. Kimlik doğrulamanız, tünelin her iki ucundaki SSL sertifikaları olacaktır, geri kalanı bu tünel içinde "açık metin" olur veya istediğiniz gibi Digest yapabilirsiniz.

NFS uç noktalarını büyük bir başarıyla "doğrulamak" için benzer bir çözüm kullandım.

Böyle bir kimlik doğrulamasının örnek kullanımı LinuxGazette'in stunnel ile Güvenli İletişiminde görülebilir


1

Nasıl yapıldığını şu küçük Docker görüntüsünde görebilirsiniz: yegor256 / squid-proxy . Kodunuzdaki sorun, yapılandırmanın acltalimattan sonra gitmesidir. Sadece onları değiştirin ve hepsi çalışmaya başlar.

Sitemizi kullandığınızda şunları okuyup anladığınızı kabul etmiş olursunuz: Çerez Politikası ve Gizlilik Politikası.
Licensed under cc by-sa 3.0 with attribution required.