Nginx https in aws

install nginx in aws linux

1
sudo amazon-linux-extras install nginx1.12

apply certificate

apply in wanwang.aliyun.com
wait a few minutes, download nginx version certificate package

config nginx

in /etc/nginx/nginx.conf
add server configuration

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
server {
listen 443;
server_name abc.com; // your domain
ssl on;
root /home/ec2-user/www/abc.com; // page file
index index.html index.htm; // index
ssl_certificate cert/214292799730473.pem; // certificate name
ssl_certificate_key cert/214292799730473.key; // certificate name
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
index index.html index.htm;
}
}
server {
listen 80;
server_name bjubi.com; // your domain
rewrite ^(.*)$ https://$host$1 permanent; // turn http to https
}

start nginx

1
2
3
4
5
// check config file
sudo /usr/sbin/nginx -t

// reload nginx
sudo /usr/sbin/nginx -s reload

some useful command

1
2
3
4
5
// start in manual
sudo /usr/sbin/nginx -c /etc/nginx/nginx.conf
sudo service nginx stop // stop
sudo service nginx start // start
sudo service nginx restart // restart

https://www.cnblogs.com/tianhei/p/7726505.html