- Install nginx nya terlebih dahulu
- apt-get install nginx atau yum install nginx
- Beli SSL nya dulu di Geotrust atau di tempat lain
- Buat folder untuk SSL nya
mkdir /etc/nginx/ssl
kemudian buat / simpan file .crt dan .key nya di folder ini misal
server2020.crt dan server2020.key
- edit config nginx
nano /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name xxx.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443;
server_name xxx.com;
root /usr/share/nginx/html/cacti/;
index index.php index.html index.htm;
# ssl_certificate /etc/nginx/cert.pem;
# ssl_certificate_key /etc/nginx/cert.key;
ssl on;
ssl_certificate /etc/nginx/ssl/server2020.crt;
ssl_certificate_key /etc/nginx/ssl/server2020.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
try_files $uri $uri/ /index.html;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
- Restart Service Nginx
/etc/init.d/nginx restart