क्या आप उबंटू लिनक्स पर HTTPS के साथ स्क्वीड स्थापित करना सीखना चाहेंगे? इस ट्यूटोरियल में, हम आपको दिखाने के लिए जा रहे हैं कि उबंटू लिनक्स पर प्रॉक्सी सर्वर स्क्विड को कैसे इंस्टॉल और कॉन्फ़िगर किया जाए।

इस ट्यूटोरियल का परीक्षण Ubuntu 18.04 पर किया गया था।
यह ट्यूटोरियल स्क्वीड 4.5 पर परीक्षण किया गया था।

हार्डवेयर सूची:

निम्न अनुभाग इस विद्रूप ट्यूटोरियल को बनाने के लिए उपयोग किए गए उपकरणों की सूची प्रस्तुत करता है।

ऊपर सूचीबद्ध हार्डवेयर का हर टुकड़ा अमेज़न की वेबसाइट पर पाया जा सकता है।

व्यंग्य संबंधित ट्यूटोरियल:

इस पृष्ठ पर, हम स्क्वीड से संबंधित ट्यूटोरियल की सूची तक त्वरित पहुंच प्रदान करते हैं।

उबंटू लिनक्स पर स्क्वीड स्थापित करें

हमें सही तारीख और समय को कॉन्फ़िगर करने की आवश्यकता है क्योंकि हम प्रमाण पत्र के साथ काम करने जा रहे हैं।

लिनक्स कंसोल पर, सही टाइमज़ोन सेट करने के लिए निम्न कमांड का उपयोग करें।

# dpkg-reconfigure tzdata

Ntpdate पैकेज स्थापित करें और तुरंत सही दिनांक और समय सेट करें।

# apt-get install ntpdate
# ntpdate pool.ntp.br

हमारे उदाहरण में, Ntpdate कमांड का उपयोग ब्राज़ीलियाई सर्वर पूल

एनटीपी सेवा स्थापित करते हैं।

# timedatectl set-ntp 0
# apt-get install ntp

NTP वह सेवा है जो हमारे सर्वर को अपडेट रखेगी।

अपने उबंटू लिनक्स पर कॉन्फ़िगर की गई तारीख और समय की जांच करने के लिए कमांड तिथि का उपयोग करें।

# date

यदि सिस्टम ने सही दिनांक और समय दिखाया है, तो इसका मतलब है कि आपने सभी चरणों का सही ढंग से पालन किया है।

आवश्यक पैकेजों को स्थापित करने के लिए निम्न आदेशों का उपयोग करें।

# apt-get update
# apt-get install build-essential openssl libssl-dev pkg-config

स्क्वीड पैकेज को डाउनलोड, संकलित और स्थापित करें।

# mkdir /downloads
# cd /downloads
# wget http://www.squid-cache.org/Versions/v4/squid-4.5.tar.gz
# tar -zxvf squid-4.5.tar.gz
# cd squid-4.5
# ./configure --with-default-user=proxy --with-openssl --enable-ssl-crtd
# make
# make install

स्क्वीड HTTPS / SSL पर्यावरण को कॉन्फ़िगर करें

अब, आपको अपने सिस्टम पर filessl.cnf फ़ाइल का स्थान ढूंढना चाहिए।

खोजने के बाद, आपको filessl.cnf फ़ाइल को संपादित करना होगा।

# updatedb
# vi /etc/ssl/openssl.cnf

यहां मूल फ़ाइल है, हमारे कॉन्फ़िगरेशन से पहले और टिप्पणियों के बिना।

HOME = .
RANDFILE = $ENV::HOME/.rnd
oid_section = new_oids[ new_oids ] tsa_policy1 = 1.2.3.4.1
tsa_policy2 = 1.2.3.4.5.6
tsa_policy3 = 1.2.3.4.5.7

[ ca ]

default_ca = CA_default # The default ca section

[ CA_default ]

dir = ./demoCA # Where everything is kept
certs = $dir/certs # Where the issued certs are kept
crl_dir = $dir/crl # Where the issued crl are kept
database = $dir/index.txt # database index file.
# several certs with same subject.
new_certs_dir = $dir/newcerts # default place for new certs.
certificate = $dir/cacert.pem # The CA certificate
serial = $dir/serial # The current serial number
crlnumber = $dir/crlnumber # the current crl number
# must be commented out to leave a V1 CRL
crl = $dir/crl.pem # The current CRL
private_key = $dir/private/cakey.pem# The private key
RANDFILE = $dir/private/.rand # private random number file
x509_extensions = usr_cert # The extensions to add to the cert
name_opt = ca_default # Subject Name options
cert_opt = ca_default # Certificate field options
default_days = 365 # how long to certify for
default_crl_days= 30 # how long before next CRL
default_md = default # use public key default MD
preserve = no # keep passed DN ordering
policy = policy_match

[ policy_match ]

countryName = match
stateOrProvinceName = match
organizationName = match
organizationalUnitName = optional
commonName = supplied
emailAddress = optional[ policy_anything ] countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional

[ req ]

default_bits = 2048
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
attributes = req_attributes
x509_extensions = v3_ca # The extensions to add to the self signed cert
string_mask = utf8only

[ req_distinguished_name ]

countryName = Country Name (2 letter code)
countryName_default = AU
countryName_min = 2
countryName_max = 2
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Some-State
localityName = Locality Name (eg, city)
0.organizationName = Organization Name (eg, company)
0.organizationName_default = Internet Widgits Pty Ltd
organizationalUnitName = Organizational Unit Name (eg, section)
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_max = 64
emailAddress = Email Address
emailAddress_max = 64

[ req_attributes ]

challengePassword = A challenge password
challengePassword_min = 4
challengePassword_max = 20
unstructuredName = An optional company name[ usr_cert ] basicConstraints=CA:FALSE
nsComment = "OpenSSL Generated Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer

[ v3_req ]

basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment

[ v3_ca ]

subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = critical,CA:true

[ crl_ext ]

authorityKeyIdentifier=keyid:always

[ proxy_cert_ext ]

basicConstraints=CA:FALSE
nsComment = "OpenSSL Generated Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo

[ tsa ]

default_tsa = tsa_config1 # the default TSA section

[ tsa_config1 ]

dir = ./demoCA # TSA root directory
serial = $dir/tsaserial # The current serial number (mandatory)
crypto_device = builtin # OpenSSL engine to use for signing
signer_cert = $dir/tsacert.pem # The TSA signing certificate
# (optional)
certs = $dir/cacert.pem # Certificate chain to include in reply
# (optional)
signer_key = $dir/private/tsakey.pem # The TSA private key (optional)
signer_digest = sha256 # Signing digest to use. (Optional)
default_policy = tsa_policy1 # Policy if request did not specify it
# (optional)
other_policies = tsa_policy2, tsa_policy3 # acceptable policies (optional)
digests = sha1, sha256, sha384, sha512 # Acceptable message digests (mandatory)
accuracy = secs:1, millisecs:500, microsecs:100 # (optional)
clock_precision_digits = 0 # number of digits after dot. (optional)
ordering = yes # Is ordering defined for timestamps?
# (optional, default: no)
tsa_name = yes # Must the TSA name be included in the reply?
# (optional, default: no)
ess_cert_id_chain = no # Must the ESS cert id chain be included?
# (optional, default: no)

Key3sage कॉन्फ़िगरेशन को V3_CA क्षेत्र में जोड़ें।

[ v3_ca ]

keyUsage = cRLSign, keyCertSign

आवश्यक SSL फ़ोल्डर इन्फ्रास्ट्रक्चर बनाएँ।

# mkdir /usr/local/squid/etc/ssl_cert -p
# chown proxy:proxy /usr/local/squid/etc/ssl_cert -R
# chmod 700 /usr/local/squid/etc/ssl_cert -R
# cd /usr/local/squid/etc/ssl_cert

एक स्व-हस्ताक्षरित प्रमाणन प्राधिकरण बनाएं।

# openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -extensions v3_ca -keyout myCA.pem -out myCA.pem

......................................................................+++
......................................+++
writing new private key to 'myCA.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:BR
State or Province Name (full name) [Some-State]:Rio de Janeiro
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:TECHEXPERT 
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []: firewall.techexpert.tips
Email Address []:

DER प्रारूप का उपयोग करके स्व-हस्ताक्षरित प्रमाणीकरण प्राधिकारी प्रमाणपत्र निर्यात करें

# openssl x509 -in myCA.pem -outform DER -out myCA.der

जरूरी! आपको क्लाइंट कंप्यूटर पर MyCA.DER आयात करना होगा।

प्रारंभिक एसएसएल डेटाबेस बनाएँ।

# /usr/local/squid/libexec/security_file_certgen -c -s /usr/local/squid/var/logs/ssl_db -M 4MB
# chown proxy:proxy /usr/local/squid/var/logs/ssl_db -R

प्रमाणपत्र प्राधिकरण प्रमाणपत्र आयात करें

आपको कंप्यूटर चलाने वाली विंडोज़ में MyCA.DER फ़ाइल की प्रतिलिपि बनाने की आवश्यकता है।

विंडोज चलाने वाले क्लाइंट कंप्यूटर पर, MyCA.DER फाइल पर डबल क्लिक करें।

सर्टिफिकेट इंस्टॉल बटन पर क्लिक करें।

Squid Certificate installation

विकल्प का चयन करें: स्थानीय मशीन।

Squid HTTPS Certificate Local machine

विकल्प का चयन करें: सभी प्रमाणपत्रों को निम्नलिखित स्टोर में रखें।

Squid HTTPS Certificate store

विश्वसनीय रूट प्रमाणीकरण प्राधिकारी नामक फ़ोल्डर का चयन करें।

Squid - Trusted Root Certitication Authorities

आपने प्रमाणपत्र स्थापना पूर्ण कर ली है।

HTTPS के लिए स्क्वीड कॉन्फ़िगर करें

यहां स्क्वीड पैकेज द्वारा स्थापित मूल स्क्विड कॉन्फ़िगरेशन फाइल है।

# vi /usr/local/squid/etc/squid.conf

acl localnet src 0.0.0.1-0.255.255.255
acl localnet src 10.0.0.0/8
acl localnet src 100.64.0.0/10
acl localnet src 169.254.0.0/16
acl localnet src 172.16.0.0/12
acl localnet src 192.168.0.0/16
acl localnet src fc00::/7
acl localnet src fe80::/10
acl SSL_ports port 443
acl Safe_ports port 80
acl Safe_ports port 21
acl Safe_ports port 443
acl Safe_ports port 70
acl Safe_ports port 210
acl Safe_ports port 1025-65535
acl Safe_ports port 280
acl Safe_ports port 488
acl Safe_ports port 591
acl Safe_ports port 777
acl CONNECT method CONNECT
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 3128
coredump_dir /usr/local/squid/var/cache/squid
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

यहाँ हमारे विन्यास के साथ नई फ़ाइल है।

# vi /usr/local/squid/etc/squid.conf

acl localnet src 192.168.0.0/24
acl step1 at_step SslBump1
ssl_bump peek step1
ssl_bump bump all
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
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 3128 ssl-bump cert=/usr/local/squid/etc/ssl_cert/myCA.pem generate-host-certificates=on dynamic_cert_mem_cache_size=4MB
sslcrtd_program /usr/local/squid/libexec/security_file_certgen -s /usr/local/squid/var/logs/ssl_db -M 4MB
coredump_dir /usr/local/squid/var/cache/squid
cache_dir ufs /usr/local/squid/var/cache/squid 1000 16 256 # 1GB as Cache
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

मेरा विन्यास अभी बुनियादी है।

यह अत्यधिक अनुशंसित है कि आप अपने कॉन्फ़िगरेशन को बेहतर बनाने के लिए इस कॉन्फ़िगरेशन फ़ाइल का अध्ययन करें।

आवश्यक कैश फ़ोल्डर बनाने के लिए निम्न कमांड का उपयोग करें।

# chown -R proxy:proxy /usr/local/squid -R
# /usr/local/squid/sbin/squid -z

स्क्वीड सेवा शुरू करने के लिए निम्नलिखित कमांड का उपयोग करें।

# /usr/local/squid/sbin/squid -d 10

यदि सब कुछ सही ढंग से काम करता है, तो आपको स्क्रीन पर निम्न संदेश देखने चाहिए:

Created PID file (https://d1ny9casiyy5u5.cloudfront.net/usr/local/squid/var/run/squid.pid)
Set Current Directory to /usr/local/squid/var/cache/squid
Starting Squid Cache version 4.5 for x86_64-pc-linux-gnu...
Service Name: squid
Process ID 20605
Process Roles: worker
With 1024 file descriptors available
Initializing IP Cache...
DNS Socket created at [::], FD 5
DNS Socket created at 0.0.0.0, FD 9
Adding nameserver 127.0.0.53 from /etc/resolv.conf
Adding domain us-west-2.compute.internal from /etc/resolv.conf
helperOpenServers: Starting 5/32 'security_file_certgen' processes
Logfile: opening log daemon:/usr/local/squid/var/logs/access.log
Logfile Daemon: opening log /usr/local/squid/var/logs/access.log
Store logging disabled
Swap maxSize 0 + 262144 KB, estimated 20164 objects
Target number of buckets: 1008
Using 8192 Store buckets
Max Mem size: 262144 KB
Max Swap size: 0 KB
Using Least Load store dir selection
Set Current Directory to /usr/local/squid/var/cache/squid
Finished loading MIME types and icons.
HTCP Disabled.
Squid plugin modules loaded: 0
Adaptation support is off.
Accepting SSL bumped HTTP Socket connections at local=[::]:3128 remote=[::] FD 22 flags=9
2019/01/18 15:33:59 kid1| storeLateRelease: released 0 objects

इंस्टॉलेशन का परीक्षण करने के लिए, अपने आंतरिक नेटवर्क पर स्थित कंप्यूटर पर जाएं और स्क्वीड सर्वर के आईपी पते और टीसीपी पोर्ट 3128 को प्रॉक्सी सर्वर के रूप में उपयोग करने के लिए इसके ब्राउज़र को कॉन्फ़िगर करें।

HTTPS वेबसाइट तक पहुँचने और अपने प्रमाणपत्र को सत्यापित करने का प्रयास करें।

हमारे उदाहरण में, हम Google.com वेबसाइट पर पहुंच रहे हैं।

स्क्वीड प्रॉक्सी स्वचालित रूप से सभी ग्राहकों के लिए नकली HTTPS प्रमाण पत्र बनाएगा।

Squid HTTPS Proxy Example