Ubuntu 16.04下Nginx配置HTTPS

栏目: 服务器 · Nginx · 发布时间: 8年前

内容简介:Ubuntu 16.04下Nginx配置HTTPS

下面记录下64位Ubuntu 16.04.1下,Nginx 1.10.1配置HTTPS的方法,Ubuntu下apt-get install nginx 的 Nginx默认是支持SSL的。

1、生成自签名证书:

cd /var/www

mkdir ssl

cd ssl

sudo openssl genrsa -des3 -out server.key 1024 

sudo openssl req -new -key server.key -out server.csr

sudo openssl rsa -in server.key -out server_nopwd.key 

sudo openssl x509 -req -days 365 -in server.csr -signkey server_nopwd.key -out server.crt 

其中证书的生成过程大致如下

linuxidc@ubuntu:~$ sudo openssl req -new -key server.key -out server.csr

Enter pass phrase for server.key:  ←输入第一步中生成server.key时设置的密码 

You are about to be asked to enter information that will be incorporated 

into your certificate request. 

What you are about to enter is what is called a Distinguished Name or a DN. 

There are quite a few fields but you can leave some blank 

For some fields there will be a default value, 

If you enter '.', the field will be left blank. 

----- 

Country Name (2 letter code) [AU]:CN ←输入国家代码 

State or Province Name (full name) [Some-State]:CHONGQING ← 输入省名 

Locality Name (eg, city) []:CHONGQING ←输入城市名 

Organization Name (eg, company) [Internet Widgits Pty Ltd]:MIKE ← 输入公司名 

Organizational Unit Name (eg, section) []:MIKE ← 输入组织单位名 

Common Name (eg, YOUR name) []:www.mike.me ← 输入主机名 

Email Address []:easylife206@gmail.com ←输入电子邮箱地址 

← 回车

← 回车

2、配置Nginx HTTPS访问:

sudo vim /etc/nginx/sites-available/default

sudo vim /etc/nginx/sites-available/default

server {

listen 443 ssl default_server;

listen [::]:443 ssl default_server;

###其他配置

ssl                  on; 

ssl_certificate      /var/www/ssl/server.crt; 

ssl_certificate_key  /var/www/ssl/server_nopwd.key;

###

OK,然后我们重新加载下nginx配置文件: service nginx restart

CentOS 7下Nginx服务器的安装配置  http://www.linuxidc.com/Linux/2017-04/142986.htm

CentOS上安装Nginx服务器实现虚拟主机和域名重定向 http://www.linuxidc.com/Linux/2017-04/142642.htm

CentOS 6.8 安装LNMP环境(Linux+Nginx+MySQL+PHP) http://www.linuxidc.com/Linux/2017-04/142880.htm

Linux下安装 PHP 环境并配置Nginx支持php-fpm模块 http://www.linuxidc.com/Linux/2017-05/144333.htm

Nginx服务的SSL认证和htpasswd认证 http://www.linuxidc.com/Linux/2017-04/142478.htm

Linux中安装配置Nginx及参数详解 http://www.linuxidc.com/Linux/2017-05/143853.htm

Nginx日志过滤 使用ngx_log_if不记录特定日志 http://www.linuxidc.com/Linux/2014-07/104686.htm

CentOS 7.2下Nginx+PHP+MySQL+Memcache缓存服务器安装配置 http://www.linuxidc.com/Linux/2017-03/142168.htm

CentOS6.9编译安装Nginx1.4.7 http://www.linuxidc.com/Linux/2017-06/144473.htm

Nginx 的详细介绍 请点这里

Nginx 的下载地址 请点这里

本文永久更新链接地址 http://www.linuxidc.com/Linux/2017-06/144806.htm


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Joy of X

The Joy of X

Niall Mansfield / UIT Cambridge Ltd. / 2010-7-1 / USD 14.95

Aimed at those new to the system seeking an overall understanding first, and written in a clear, uncomplicated style, this reprint of the much-cited 1993 classic describes the standard windowing syste......一起来看看 《The Joy of X》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器