क्या आप अपनी अपाचे वेबसाइट को सुरक्षित HTTP सर्टिफिकेट का उपयोग करने से सुरक्षित करना सीखना चाहेंगे? इस ट्यूटोरियल में, हम आपको सिक्योरिटी अपाचे के लिए आवश्यक सभी कदम दिखाने जा रहे हैं, जो उबंटू लिनक्स पर एन्क्रिप्ट करते हैं

• उबंटू संस्करण: 18.04

स्थापना का वर्णन करने के लिए, हम अपने एक डोमेन का उपयोग करने जा रहे हैं, जिसका नाम MINING-POOL.NINJA है।

आपको कॉन्फ़िगरेशन फ़ाइलों को बदलने और हमारे डोमेन नाम को अपने डोमेन नाम से MINING-POOL.NINJA बदलने की आवश्यकता होगी।

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

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

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

अपाचे संबंधित ट्यूटोरियल:

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

1. एक डोमेन नाम खरीद

सबसे पहले, आपको एक्सेस करने की आवश्यकता है GODADDY और एक खाता बनाएँ।

इस खाते का उपयोग DNS डोमेन खरीदने के लिए किया जाएगा।

हमारे उदाहरण में, हम MINING-POOL.NINJA नाम का डोमेन खरीदते हैं।

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

GoDaddy मेरी पसंदीदा पसंद है।

2. DNS एंट्री को कॉन्फ़िगर करें

अब, आपको अपने अपाचे वेब सर्वर की ओर इशारा करते हुए एक DNS रजिस्ट्री को कॉन्फ़िगर करने की आवश्यकता है।

DNS डोमेन खरीदने के बाद, आपको अपने वेबसाइट के पते को Ubuntu Linux चलाने वाले कंप्यूटर पर इंगित करते हुए DNS प्रविष्टि बनाने की आवश्यकता है।

हमारे उदाहरण में, हमने एक DNS प्रविष्टि बनाई जो कि डोमेन MINING-POOL.NINJA को IP पते 35.163.100.49 पर दर्शाती है।

HTTPS DNS Entry

लिनक्स चलाने वाले कंप्यूटर पर अपने DNS कॉन्फ़िगरेशन का परीक्षण करने के लिए निम्न कमांड का उपयोग करें।

# apt-get update
# apt-get install dnsutils
# nslookup mining-pool.ninja

Non-authoritative answer:
Name: mining-pool.ninja
Address: 35.163.100.49

ऊपर दिए गए आदेश की पुष्टि की गई है कि डोमेन आईपी पते की ओर इशारा करता है 35.163.100.49।

3. अपाचे वेब सर्वर स्थापित करें

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

हमें अपाचे वेब सर्वर और सभी आवश्यक सॉफ़्टवेयर स्थापित करने की आवश्यकता है।

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

# apt-get update
# apt-get install apache2 php7.2 php7.2-mysql libapache2-mod-php7.2
# apt-get install openssl

Apache mod_rewrite को सक्षम करें और Apache2.conf फ़ाइल को संपादित करें।

# a2enmod rewrite
# vi /etc/apache2/apache2.conf

फ़ाइल के अंत में, निम्न पंक्तियाँ जोड़ें।

<Directory /var/www/html>
AllowOverride All
</Directory>

अपनी वेबसाइट पर एक अपाचे वर्चुअलाइज़ कॉन्फ़िगरेशन फ़ाइल बनाएँ।

# vi /etc/apache2/sites-available/mining-pool.conf

ध्यान रखें कि आपका वर्चुअलहोस्ट नाम और स्थान मेरा जैसा नहीं हो सकता है।

एक उदाहरण के रूप में, यहाँ हमारी फ़ाइल की सामग्री है:

<VirtualHost *:80>
ServerAdmin nobody@care.com
DocumentRoot /websites/www
ServerName mining-pool.ninja

<Directory /websites/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /websites/logs/error.log
CustomLog /websites/logs/access.log combined
LogLevel error
</VirtualHost>

आवश्यक फ़ोल्डरों की सूची बनाएं।

सभी फ़ोल्डरों पर सही फ़ाइल अनुमति सेट करें।

ध्यान रखें कि आपका फ़ोल्डर स्थान मेरा जैसा नहीं हो सकता है।

# mkdir /websites
# cd /websites
# mkdir www logs
# chown www-data.www-data /websites -R

अपने अपाचे वर्चुअलाइज कॉन्फ़िगरेशन को सक्षम करें और अपाचे सेवा को पुनः आरंभ करें।

# a2ensite mining-pool.conf
# systemctl reload apache2

4. अपाचे पर नि: शुल्क HTTPS प्रमाणपत्र कॉन्फ़िगर करें

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

# apt-get install software-properties-common
# add-apt-repository universe
# add-apt-repository ppa:certbot/certbot
# apt-get update
# apt-get install python-certbot-apache

सर्टिफिकेट स्क्रिप्ट के लिए उपयोगकर्ता को पूरी तरह कार्यात्मक अपाचे वेब सर्वर की आवश्यकता होती है।

हमने पहले ही अपना Apache Virtualhost इंस्टॉलेशन और कॉन्फ़िगरेशन समाप्त कर लिया है।

निम्न आदेश अनुरोध का उपयोग करें और Apache मुक्त HTTPS प्रमाणपत्र स्थापित करें।

ध्यान रखें कि आपका डोमेन नाम मेरा जैसा नहीं होना चाहिए।

# certbot --apache -d mining-pool.ninja

• प्रेस (ए) सेवा की शर्तों से सहमत होने के लिए।
• अपने ई-मेल को साझा करने और न्यूज़लेटर्स प्राप्त करने के लिए (वाई) दबाएं।
• अपने HTTP वेबसाइट को HTTPS संस्करणों में स्वचालित रूप से पुनर्निर्देशित करने के लिए (2) दबाएँ।

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): techexpert.tips@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for mining-pool.ninja
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/mining-pool-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/mining-pool-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/mining-pool-le-ssl.conf

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/mining-pool.conf to ssl vhost in /etc/apache2/sites-available/mining-pool-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://mining-pool.ninja

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=mining-pool.ninja
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/mining-pool.ninja/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/mining-pool.ninja/privkey.pem
Your cert will expire on 2019-03-19. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

सिस्टम स्वचालित रूप से प्रमाणपत्र का अनुरोध करेगा और आपकी अपाचे वेब सर्वर को आपकी वेबसाइट के HTTPS संस्करण में सभी HTTP एक्सेस को रीडायरेक्ट करने के लिए कॉन्फ़िगर करेगा।

हमारे उदाहरण में, सिस्टम ने एक HTTPS Virtualhost कॉन्फ़िगरेशन फ़ाइल बनाई, जिसका नाम माइनिंग-पूल-le-ssl.conf है

यहाँ HTTPS Virtualhost कॉन्फ़िगरेशन फ़ाइल माइनिंग-पूल-le-ssl.conf की सामग्री है:

<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin nobody@care.com
DocumentRoot /websites/www
ServerName mining-pool.ninja

<Directory /websites/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /websites/logs/error.log
CustomLog /websites/logs/access.log combined
LogLevel error

SSLCertificateFile /etc/letsencrypt/live/mining-pool.ninja/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mining-pool.ninja/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

KEY फ़ाइल में आपकी प्रमाणपत्र निजी कुंजी होती है और उसे हर समय सुरक्षित स्थान पर रखा जाना चाहिए।

यहाँ प्रमुख फ़ाइल की सामग्री है: /etc/letsencrypt/live/mining-pool.ninja/privkey.pem

-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCwGYFx4kcQmYC5
gJftnjZhWNVZkIL7wSMTFtFfIY37PNbVNeJ11HoudX8HWout8qXOxBvHE8oUtzrO
/956cCVNsdY+eXZVVwUhjeSRT9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O9cwy
/TM4tL9uo/W77r/jsPXXdRPARD98Z1xk3l1NMvaxZURtU/NN0On5iUABQQKBgGIu
FiER0R3iAF68WLAT7TVx4UgK2nsdO2eQCXkJDhpAyPEIjK8RWu/10oaS4k4guXYW
IYut3+dZpCFAVVCMwvaSlSMZbkk4464VBM3zxgRvxyoW1DXuO2ihWiD/fNZ8opTf
l7EcqR2fjOFKhgUF7qaZYG4GDYxHVuNhSkzDsdvHAoGBAIfDk7fLsG/BYROxJpzN
b1CoG8DE+DKYTWwMWW45rDF0ImbC6H3fg876CeZ3YKGWqt9qkha7gnGGVRRufP15
O7ZEXebZXeDYafXSNcnqSe7FSNtVr1eFlTWmL8OiWQuaqxjs/VogdWfhkEGPISVF
AOM3I6XSGx4NxW2RgYmvQZ4O
-----END PRIVATE KEY-----

एचटीटीपीएस संस्करण के सभी HTTP अनुरोधों को पुनर्निर्देशित करने के लिए सिस्टम ने स्वचालित रूप से आपकी मूल अपाचे वर्चुअलाइज़ कॉन्फ़िगरेशन फ़ाइल बदल दी।

यहां अपडेट की गई मूल HTTP वर्चुअलबॉक्सहोस्ट कॉन्फ़िगरेशन फ़ाइल माइनिंग-पूल की सामग्री है ।conf:

<VirtualHost *:80>
ServerAdmin nobody@care.com
DocumentRoot /websites/www
ServerName mining-pool.ninja

<Directory /websites/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /websites/logs/error.log
CustomLog /websites/logs/access.log combined
LogLevel error
RewriteEngine on
RewriteCond %{SERVER_NAME} =mining-pool.ninja
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost>

5. अपनी Apache HTTPS वेबसाइट का परीक्षण करें

अपनी स्थापना का परीक्षण करने के लिए, अपना ब्राउज़र खोलें और अपनी वेबसाइट HTTP पता दर्ज करें।

हमारे उदाहरण में, निम्न URL ब्राउज़र में दर्ज किया गया था:

• http://mining-pool.ninja

HTTP संस्करण के बजाय, आपकी वेबसाइट का HTTPS संस्करण प्रस्तुत किया जाना चाहिए।

Lets Encrypt Apache

बधाई हो, आपका Apache कॉन्फ़िगरेशन अब LET'S ENCRYPT मुक्त HTTPS प्रमाणपत्र का उपयोग कर रहा है।

6. अपाचे HTTPS प्रमाणपत्र को नवीनीकृत करें

आपको इस बात से अवगत होना चाहिए कि लेट्स एनक्रिप्ट के सर्टिफिकेट केवल नब्बे दिनों के लिए मान्य हैं।

Apache HTTPS Free Certificate

सिस्टम किसी भी प्रमाणपत्र को स्वचालित रूप से नवीनीकृत करने के लिए एक निर्धारित कार्य बनाता है जो समाप्ति के तीस दिनों के भीतर होता है।

निर्धारित कार्य नाम सर्टिफिकेट है और यह निर्देशिका /etc/cron.d के अंदर स्थित है।

यहाँ /etc/cron.d/certbot फ़ाइल की सामग्री दी गई है:

# /etc/cron.d/certbot: crontab entries for the certbot package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc. Renewal will only occur if expiration
# is within 30 days.
#
# Important Note! This cronjob will NOT be executed if you are
# running systemd as your init system. If you are running systemd,
# the cronjob.timer function takes precedence over this cronjob. For
# more details, see the systemd.timer manpage, or use systemctl show
# certbot.timer.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

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

# certbot renew --dry-run

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

Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/mining-pool.ninja.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert not due for renewal, but simulating renewal for dry run
Plugins selected: Authenticator apache, Installer apache
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for mining-pool.ninja
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed with reload of apache server; fullchain is
/etc/letsencrypt/live/mining-pool.ninja/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates below have not been saved.)

Congratulations, all renewals succeeded. The following certs have been renewed:
/etc/letsencrypt/live/mining-pool.ninja/fullchain.pem (success)
** DRY RUN: simulating 'certbot renew' close to cert expiry
** (The test certificates above have not been saved.)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.