centos6.8下配置https服务器

1.1 环境

l  系统环境:内核环境为2.6.32版本  64位的CentOS release 6.8 (Final)

[root@localhost ~]# uname -a

Linux localhost 2.6.32-696.3.1.el6.x86_64 #1 SMP Tue May 30 19:52:55 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

[root@localhost ~]# cat /etc/redhat-release

CentOS release 6.8 (Final)

l  网络环境:确保能够访问网络

[root@localhost ~]# ping -c 2 www.baidu.com

PING www.a.shifen.com (220.181.112.244) 56(84) bytes of data.

64 bytes from 220.181.112.244: icmp_seq=1 ttl=53 time=4.82 ms

64 bytes from 220.181.112.244: icmp_seq=2 ttl=53 time=4.89 ms

--- www.a.shifen.com ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1006ms

rtt min/avg/max/mdev = 4.820/4.856/4.892/0.036 ms

1.2 安装nginx:这里直接使用yum安装

[root@localhost ~]# yum install -y nginx

Loaded plugins: fastestmirror

Setting up Install Process

Repository epel is listed more than once in the configuration

Determining fastest mirrors

……

………省略

Complete!

[root@localhost ~]#  rpm -q nginx

nginx-1.10.2-1.el6.x86_64

可以看到yum 安装的nginx的版本为nginx-1.10.2

1.3 上传已经相关证书

创建目录并进入ssl目录

[root@localhost ~]# mkdir -p /etc/nginx/ssl

[root@localhost ~]# cd /etc/nginx/ssl

上传文件(此处可根据具体情况上传文件)

[root@localhost ssl]# yum install -y lrzsz

[root@localhost ssl]# rz -y

弹出对话框,双击选中相关证书文件点击ok上传到服务器/etc/nginx/ssl目录下

1.4 配置nginx文件

清空原有的ssl.conf文件

[root@localhost ssl]# >/etc/nginx/conf.d/ssl.conf

加入以下内容,并根据自己的需求更改IP,域名和证书文件

[root@localhost ssl]# cat /etc/nginx/conf.d/ssl.conf

#

# HTTPS server configuration

#

proxy_connect_timeout 60;

proxy_send_timeout 120;

proxy_read_timeout 360;

proxy_buffer_size 256k;

proxy_buffers 128 32k;

proxy_busy_buffers_size 512k;

proxy_temp_file_write_size 256k;

proxy_max_temp_file_size 128m;

proxy_redirect off;

proxy_headers_hash_max_size 51200;

proxy_headers_hash_bucket_size 6400;

proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;

proxy_temp_path  /dev/shm/proxy_temp;

proxy_cache_path /dev/shm/proxy_cache levels=1:2 keys_zone=cache_one:300m inactive=1d max_size=1g;

gzip  on;

gzip_min_length  1k;

gzip_buffers     16 16k;

gzip_http_version 1.1;

gzip_comp_level 2;

gzip_types       text/plain application/x-javascript text/css application/xml;gzip_vary on;

upstream www_server {

server xxx.xxx.xxx.xxx:8080 max_fails=3 fail_timeout=30s;

}

server {

listen 443 ssl;

server_name *.123456.com 123456.com;

ssl_certificate           ssl/123456.com.crt;

ssl_certificate_key       ssl/123456.com.key;

ssl_protocols             TLSv1 TLSv1.1 TLSv1.2;

ssl_ciphers               ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;

ssl_prefer_server_ciphers on;

location / {

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header REMOTE-HOST $remote_addr;

proxy_set_header X-Forwarded-For $remote_addr;

proxy_pass  http://www_server;

}

location ~ .*\.(jpg|jpeg|gif|png|swf|css|js|txt|htc|ico)?$ {

proxy_cache cache_one;

proxy_cache_key $host$uri$is_args$args;

add_header Cache "$upstream_cache_status";

proxy_cache_valid 200 304 30m;

proxy_cache_valid 404 500 502 503 504 3s;

proxy_cache_valid any 1h;

expires 2h;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header REMOTE-HOST $remote_addr;

proxy_set_header X-Forwarded-For $remote_addr;

proxy_pass  http://www_server;

}

}

备注:红色地方为需要自己更改的地方

备注:xxx.xxx.xxx.xxx 为您需要增加的后端的IP

1.5 检查配置并启动nginx

检查配置:是否正确(看到ok和successful表示配置正确)

[root@localhost ~]# /etc/init.d/nginx configtest

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

启动服务

[root@localhost ~]# /etc/init.d/nginx start

Starting nginx:                                            [  OK  ]

[root@localhost ~]# netstat -lnptu|grep "nginx"

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      15260/nginx

tcp        0      0 0.0.0.0:443                 0.0.0.0:*                   LISTEN      15260/nginx

可以看到已经开启了80和443端口,表示nginx已经启动成功

1.6 防火墙设置

防火墙应根据服务器具体情况配置:

这边防火墙配置如下:

[root@localhost ~]# cat /etc/sysconfig/iptables

*filter

:INPUT ACCEPT [0:0]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

-A INPUT -p icmp -j DROP

-A INPUT -i lo -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m multiport --dports 22 -j ACCEPT

-A INPUT -p tcp -m state --state NEW -m multiport --dports 80,443 -j ACCEPT

-A INPUT -j REJECT --reject-with icmp-host-prohibited

-A FORWARD -j REJECT --reject-with icmp-host-prohibited

COMMIT

重启防火墙

[root@localhost ~]# /etc/init.d/iptables restart

关闭selinux

[root@localhost ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

[root@localhost ~]# setenforce 0

到此https配置基本完成。

centos6.8下配置https服务器的更多相关文章

  1. centos6.4下配置nginx服务器更改根目录

    安装完nginx服务器后发现nginx的根目录在/usr/share/nginx/html/下,但是对于部署文件来说,在该目录下是不太习惯的,我就尝试着更改nginx访问的根目录 #  vi /etc ...

  2. Centos6.8下搭建SVN服务器

    1.Centos6.8下搭建SVN服务器 Subversion是一个自由,开源的版本控制系统.Subversion将文件存放在中心版本库里.这个版本库很像一个普通的文件服务器,不同的是,它可以记录每一 ...

  3. 阿里云ECS服务器Linux环境下配置php服务器(二)--phpMyAdmin篇

    上一篇讲了PHP服务器的基本配置,我们安装了apache,php,还有MySQL,最后还跑通了一个非常简单的php页面,有兴趣的朋友可以看我的这篇博客: 阿里云ECS服务器Linux环境下配置php服 ...

  4. Nginx 配置 HTTPS 服务器

    Nginx 配置 HTTPS 服务器 Chrome 浏览器地址栏标志着 HTTPS 的绿色小锁头从心理层面上可以给用户专业安全的心理暗示,本文简单总结一下如何在 Nginx 配置 HTTPS 服务器, ...

  5. suse linux 10 下配置vpn服务器(pptp)

     一.安装所需的软件包:      pptpd-*.rpm      ppp-*.rpm      pptp-*.rpm     一般情况下系统已经将pptp和ppp包安装好了,所以只需安装pptpd ...

  6. Linux下配置Tomcat服务器

    Linux下配置Tomcat服务器和Windows下其实差不多,可以去官网下载安装包释放或者在线下载,只是当时下载的windows.zip文件,现在下载.tar.gz格式的即可,下面使用命令行的方式安 ...

  7. centos6.4安装配置vpn服务器步骤详解

      centos6.4安装配置vpn服务器步骤详解,从安装VPN到配置VPN服务器.配置VPN服务器的路由转发功能,每一步都很详细   一.VPN服务器环境说明 操作系统:CentOS release ...

  8. Tomcat 6.0下配置HTTPS

    最近项目需要使用到https,所以回顾整理了一下,其实在tomcat的文档中已经有了详细描述,我们启动Tomcat后,可以在docs文档中找到 地址如下:http://localhost:8080/d ...

  9. ubuntu 下配置Web服务器

    ubuntu 下配置Web服务器 1.切换管理员身份 终端/文本界面输入命令: su 根据提示输入密码 注: 如果不能使用su 点击查看如何启用su2.安装MySQL5 apt-get install ...

随机推荐

  1. String和get

    在ch4的作业中暴露出了我不懂的一些问题,主要是和String有关的定义和头文件以及和get有关的函数. String 在C++中如果想定义字符串型,即String a:则需要用到头文件<str ...

  2. python中的clear

    1 a = { 2 "name":"dlrb", 3 "age":25, 4 "height":168 5 } 6 a. ...

  3. <转载>Bootstrap 入门教程 http://www.cnblogs.com/ventlam/archive/2012/05/28/2520703.html 系列

    Bootstrap建立了一个响应式的12列格网布局系统,它引入了fixed和fluid-with两种布局方式.我们从全局样式(Global Style),格网系统(Grid System),流式格网( ...

  4. 2. apache整合tomcat部署集群

    apache只有处理静态事物的能力, 而tomcat的强项就是处理动态的请求,所以apache和tomcat整合相互取长补短,由apache作为入口,如果是请求静态页面或者是静态文件,由apache直 ...

  5. leetcode998

    class Solution: def __init__(self): self.prelist = list() def preTree(self,root:TreeNode): if root ! ...

  6. AES-128-CBC C语言代码

    /** * Copyright (c) 2007, Cameron Rich * * All rights reserved. * * Redistribution and use in source ...

  7. bootsrap Collapse用法

    collapse用处还是挺多的. 使用方法先看看bootstrap官方文档:https://v3.bootcss.com/javascript/#collapse You can use a link ...

  8. day33-常见内置模块二(hashlib、shutil、configparse)

    一.hashlib算法介绍 Python的hashlib提供了常见的摘要算法,如MD5,SHA1等等. 1.什么是摘要算法呢? 摘要算法又称哈希算法.散列算法.它通过一个函数,把任意长度的数据转换为一 ...

  9. flash时间轴声音大小控制

    A2时间轴声音大小控制: var sound:Sound = new Sound(); sound.setVolume(200); 把背景音乐放到一个影片剪辑里,剪辑起名 例如bgm_mc 声音模式为 ...

  10. springboot 停止

    因springboot内嵌tomcat或jetty使得我们没法去操作服务: 因此,常常是服务起来后,要重启时会端口占用,我们只能无情的kill掉端口. 不过spring也设置有配置停止的请求: App ...