Configuring HTTPS for Leanote with Nginx

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.