1. Generate an SSL certificate
You can buy one on the internet, or make one yourself.
Here's a shell script that can automatically generate a certificate:
#!/bin/sh# Create self-signed server certificate:read-p "Enter your domain [www.example.com]:" Domainecho "Create server Key ... "OpenSSL genrsa-des3-out $DOMAIN. Key 1024echo" Create server certificate Signing request ... "subject="/c=us/st=ma rs/l=itranswarp/o=itranswarp/ou=itranswarp/cn= $DOMAIN "OpenSSL req-new-subj $SUBJECT-key $DOMAIN. Key-out $ Domain.csrecho "Remove password ..." MV $DOMAIN. Key $DOMAIN. Origin.keyopenssl rsa-in $DOMAIN. Origin.key-out $ Domain.keyecho "Sign SSL certificate ..." OpenSSL x509-req-days 3650-in $DOMAIN. Csr-signkey $DOMAIN. Key-out $DOMAIN. CRT
Suppose you get two files: a.com.crt ,a.com.key
2. Configure Nginx
Assuming that the port that Leanote is running is 9000 and the domain name is a.com, then nginx.conf can be configured as follows:
# This configuration is only HTTP partial, not full http { include /etc/nginx/mime.types; default_type application/octet-stream; upstream a.com { server localhost:9000; } # http server { listen 80; server_name a.com; # forced https # If you do not need, , please comment this line rewrite rewrite ^/(. *) https://jp_linode2.com/$1 permanent; location / { proxy_pass http://a.com; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote _addr; proxy_ set_header x-forwarded-for $proxy _add_x_forwarded_for; } } # https server { listen 443 ssl; server_name a.com; ssl_certificate /root/a.com.crt; # Modify Path, To a.com.crt, ssl_certificate_key /root/a.com.key; location / { proxy_pass http://a.com; proxy_set_header host $host; proxy_set_header X-Real-IP $remote _addr; proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for; } }}
Configuring HTTPS for Leanote using Nginx