Rocket sohbeti yüklerken ücretsiz veya satın alma kullanarak ssl yüklemeniz gerekir. Şimdi Let’Encrypt tamamen ücretsiz ssl hizmetini kullanabileceğinizi göstermeliyim. Bu sertifikanın varsayılan geçerlilik tarihi 3 aydır. Ancak sunucumda otomatik yenileme işlemini kurdum. Sunucunuz yerel ise, bu nedenle ileri bağlantı noktası için NAT sistemi kullanmalısınız.
NAT PORT 443 (LAN) ➺ 443 (WAN) << Parmenent
NAT PORT 80 (LAN) ➺ 80 (WAN) << Yalnızca kurulumdan önce ssl
Genel IP adresim: 45.251.231.171
Yerel IP adresim: 10.66.30.10
Adım # 01: Sunucu güncellemeniz ve yükseltmeniz olmalı, ardından nginx web sunucusunu kurmalısınız.
root@Rocket-Chat:~# apt-get update
root@Rocket-Chat:~# apt-get install software-properties-common python-software-properties
root@Rocket-Chat:~# apt-get install nginx
root@Rocket-Chat:~# systemctl status nginx.service
Ssl’yi yüklemeden önce, sunucunuzdan 80 bağlantı noktasını devre dışı bırakmalısınız.
root@Rocket-Chat:~# netstat -pan | grep ":80"
root@Rocket-Chat:~# pkill -f nginx
root@Rocket-Chat:~# systemctl start nginx.service
root@Rocket-Chat:~# systemctl status nginx.service
Adım # 02: Şimdi let’sencrypt ve certbot’u kurun ve nginx web sunucusunu yapılandırın.
root@Rocket-Chat:~# add-apt-repository ppa:certbot/certbot root@Rocket-Chat:~# apt-get update
root@Rocket-Chat:~# apt-get install letsencrypt
root@Rocket-Chat:~# wget https://dl.eff.org/certbot-auto -P /usr/local/bin
root@Rocket-Chat:~# chmod a+x /usr/local/bin/certbot-auto root@Rocket-Chat:~# export DOMAIN="chat.kockerim.com" root@Rocket-Chat:~# export EMAIL_ALERT="admin@kockerim.com"
Adım # 03: let’sencrypt for nginx sunucusundan ücretsiz SSL yükleyin.
root@Rocket-Chat:~# /usr/local/bin/certbot-auto certonly --standalone -d $DOMAIN --preferred-challenges http --agree-tos -n -m $EMAIL_ALERT --keep-until-expiring
Eski nginx web yapılandırma dosyasını yedekleyin ve ssl kullanmak için düzenleyin.
root@Rocket-Chat:~# cp /etc/nginx/sites-available/default /etc/nginx/sites-available/default.back
root@Rocket-Chat:~# nano /etc/nginx/sites-available/default
Adım # 04: Önceki tüm satırları bırakın ve tüm satırların altına ekleyin. Ve ssl config için alan adınızı değiştirin.
Upstream definition
upstream backend {
server 127.0.0.1:3000;
}
http to https redirection
server {
listen 80;
server_name chat.kockerim.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
HTTPS Server
server {
listen 443;
server_name chat.kockerim.com;
error_log /var/log/nginx/rocket-chat.access.log;
ssl on;
ssl_certificate /etc/letsencrypt/live/chat.kockerim.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/chat.kockerim.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE
location / {
proxy_pass http://backend/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forward-Proto http;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;
}
}
Adım # 05: nginx web sunucusunu yeniden başlatın ve yenileme komutunu çalıştırın.
root@Rocket-Chat:~# nginx -t
root@Rocket-Chat:~# service nginx restart
root@Rocket-Chat:~# certbot-auto renew